本文整理汇总了Java中android.database.Cursor.getCount方法的典型用法代码示例。如果您正苦于以下问题:Java Cursor.getCount方法的具体用法?Java Cursor.getCount怎么用?Java Cursor.getCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.database.Cursor
的用法示例。
在下文中一共展示了Cursor.getCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: transformQuickSearchCursor
import android.database.Cursor; //导入方法依赖的package包/类
private List<SuggestionsBean> transformQuickSearchCursor(Cursor data) {
List<SuggestionsBean> list = new ArrayList<>(data.getCount());
if (data.moveToFirst()) {
do {
SuggestionsBean suggestionsBean = new SuggestionsBean();
suggestionsBean.setImageId(data.getInt(0));
suggestionsBean.setName(data.getString(1));
list.add(suggestionsBean);
} while (data.moveToNext());
//not forget to override hasCode and equals in SuggestionsBean class
list =Observable.from(list).distinct().toList().toBlocking().first();
}
return list;
}
示例2: queryHasFeed
import android.database.Cursor; //导入方法依赖的package包/类
public boolean queryHasFeed() {
Log.i("sqlite", "开始");
boolean isHasFeed;
//开启事务
db.beginTransaction();
Cursor cursor = db.query("AllFeeds", null, null, null, null, null, null);
if (cursor.getCount() != 0)
isHasFeed = true;
else
isHasFeed = false;
db.setTransactionSuccessful();
db.endTransaction();
return isHasFeed;
}
示例3: AuthorRecyclerViewAdapter
import android.database.Cursor; //导入方法依赖的package包/类
public AuthorRecyclerViewAdapter(
String IdColumnName,
AuthorListFragment.OnAuthorItemClickListener listener,
Context context,
CursorListFragment cursorListFragment) {
this.booksInformationDbHelper = BooksInformationDbHelper.getInstance(context);
Cursor cursor = getCursor(
cursorListFragment.shouldDisplayDownloadOnly(),
cursorListFragment.getQueryString(),
cursorListFragment.getCurrentSortIndex());
this.context = context;
this.cursorListFragment = cursorListFragment;
init(cursor, cursor.getColumnIndex(IdColumnName));
COLUMN_AUTHOUR_NAME_ID = cursor.getColumnIndexOrThrow(BooksInformationDBContract.AuthorEntry.COLUMN_NAME_NAME);
COULMN_AUTHOUR_ID = cursor.getColumnIndexOrThrow(BooksInformationDBContract.AuthorEntry.COLUMN_NAME_ID);
COLUMN_AUTHOUR_DEATH_DATE_ID = cursor.getColumnIndexOrThrow(BooksInformationDBContract.AuthorEntry.COLUMN_NAME_DEATH_HIJRI_YEAR);
COULMN_NUMBER_OF_BOOKS = cursor.getColumnIndex(BooksInformationDBContract.AuthorEntry.COUNT_OF_BOOKS);
COULMN_HAS_DOWNLOADED_BOOKS = cursor.getColumnIndex(BooksInformationDBContract.AuthorEntry.HAS_DOWNLOADED_BOOKS);
itemCount = cursor.getCount();
mListener = listener;
}
示例4: getDownloadingVideoNum
import android.database.Cursor; //导入方法依赖的package包/类
public static int getDownloadingVideoNum() {
Cursor cursor = null;
try {
Query query = new Query(sConext.getContentResolver());
query.setUri(DOWNLOAD_VIDEO_URI);
query.setSelection("state != 4");
cursor = query(query);
int count = (cursor == null || cursor.getCount() <= 0) ? 0 : cursor.getCount();
if (!(cursor == null || cursor.isClosed())) {
cursor.close();
}
return count;
} catch (Throwable th) {
if (!(cursor == null || cursor.isClosed())) {
cursor.close();
}
}
}
示例5: cellInDbiMeasure
import android.database.Cursor; //导入方法依赖的package包/类
/**
* Check if CID (currently bts_id) is already in DBi_measure
*/
public boolean cellInDbiMeasure(int cellID) {
String query = String.format(Locale.US,
// "SELECT CID FROM DBi_bts, DBi_measure WHERE bts_id = %d", // todo E:V:A
"SELECT bts_id FROM DBi_measure WHERE bts_id = %d",
cellID);
Cursor cursor = mDb.rawQuery(query, null);
boolean exists = cursor.getCount() > 0;
cursor.close();
return exists;
}
示例6: cursorToList
import android.database.Cursor; //导入方法依赖的package包/类
private List<user> cursorToList(Cursor cursor) {
List<user> items = new ArrayList();
if (cursor.getCount() > 0) {
while (cursor.moveToNext()) {
user nam = new user();
nam.setId(cursor.getInt(cursor.getColumnIndex(KEY_ID)));
nam.setUid(cursor.getInt(cursor.getColumnIndex(KEY_UID)));
nam.setFname(cursor.getString(cursor.getColumnIndex(KEY_FNAME)));
nam.setLname(cursor.getString(cursor.getColumnIndex(KEY_LNAME)));
nam.setUsername(cursor.getString(cursor.getColumnIndex(KEY_USERNAME)));
nam.setPic(cursor.getString(cursor.getColumnIndex(KEY_PIC)));
nam.setStatus(cursor.getString(cursor.getColumnIndex(KEY_STATUS)));
nam.setPhone(cursor.getString(cursor.getColumnIndex(KEY_PHONE)));
nam.setUptime(cursor.getString(cursor.getColumnIndex(KEY_UPTIME)));
nam.setIsupdate(cursor.getInt(cursor.getColumnIndex(KEY_ISUPDATE)));
nam.setIsspecific(cursor.getInt(cursor.getColumnIndex(KEY_ISSPECEFIC)));
nam.setPicup(cursor.getInt(cursor.getColumnIndex(KEY_PICUP)));
nam.setStatusup(cursor.getInt(cursor.getColumnIndex(KEY_STATUSUP)));
nam.setPhoneup(cursor.getInt(cursor.getColumnIndex(KEY_PHONEUP)));
nam.setIsonetime(cursor.getInt(cursor.getColumnIndex(KEY_ISONETIME)));
items.add(nam);
}
}
return items;
}
示例7: cpfCadastrado
import android.database.Cursor; //导入方法依赖的package包/类
public boolean cpfCadastrado(User user){
String sql = "SELECT cpf FROM " + TABELA + " WHERE cpf=" + user.getCpf() +";";
Cursor cursor = getReadableDatabase().rawQuery(sql, null);
if (cursor.getCount() > 0){
cursor.close();
return true;
} else{
cursor.close();
return false;
}
}
示例8: getMediaBeanWithVideo
import android.database.Cursor; //导入方法依赖的package包/类
/**
* 根据地址获取视频相关信息
*/
public static MediaBean getMediaBeanWithVideo(Context context, String originalPath) {
ContentResolver contentResolver = context.getContentResolver();
List<String> projection = new ArrayList<>();
projection.add(MediaStore.Video.Media._ID);
projection.add(MediaStore.Video.Media.TITLE);
projection.add(MediaStore.Video.Media.DATA);
projection.add(MediaStore.Video.Media.BUCKET_ID);
projection.add(MediaStore.Video.Media.BUCKET_DISPLAY_NAME);
projection.add(MediaStore.Video.Media.MIME_TYPE);
projection.add(MediaStore.Video.Media.DATE_ADDED);
projection.add(MediaStore.Video.Media.DATE_MODIFIED);
projection.add(MediaStore.Video.Media.LATITUDE);
projection.add(MediaStore.Video.Media.LONGITUDE);
projection.add(MediaStore.Video.Media.SIZE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
projection.add(MediaStore.Video.Media.WIDTH);
projection.add(MediaStore.Video.Media.HEIGHT);
}
Cursor cursor = contentResolver.query(
MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
projection.toArray(new String[projection.size()]),
MediaStore.Images.Media.DATA + "=?",
new String[]{originalPath}, null);
MediaBean mediaBean = null;
if (cursor != null && cursor.getCount() > 0) {
cursor.moveToFirst();
mediaBean = parseVideoCursorAndCreateThumImage(context, cursor);
}
if (cursor != null && !cursor.isClosed()) {
cursor.close();
}
return mediaBean;
}
示例9: copyData
import android.database.Cursor; //导入方法依赖的package包/类
/** copies data from Android's media db to ours */
private static int copyData (ContentResolver cr, String minId) {
int imported = 0;
String where = WHERE_ALL;
String[] whereArgs = null;
if (minId != null) {
where = WHERE_MIN_ID;
whereArgs = new String[] { minId };
}
Cursor allFiles = CustomCursor.wrap(cr.query(MediaStore.Files.getContentUri("external"),
FILES_PROJECTION, where, whereArgs, BaseColumns._ID));
if (allFiles != null) {
int count = allFiles.getCount();
int ccount = allFiles.getColumnCount();
if (count > 0) {
// transaction size limited, acts like buffered output stream and auto-flushes queue
BulkInserter inserter = new BulkInserter(MusicStoreInternal.FILES_IMPORT, cr, 2000);
if (DBG) Log.d(TAG, "found items to import:" + count);
while (allFiles.moveToNext()) {
ContentValues cv = new ContentValues(ccount);
DatabaseUtils.cursorRowToContentValues(allFiles, cv);
inserter.add(cv);
}
imported = inserter.execute();
}
allFiles.close();
}
return imported;
}
示例10: cursorToRepo
import android.database.Cursor; //导入方法依赖的package包/类
private static Repo cursorToRepo(Cursor cursor) {
Repo repo = null;
if (cursor != null) {
if (cursor.getCount() > 0) {
cursor.moveToFirst();
repo = new Repo(cursor);
}
cursor.close();
}
return repo;
}
示例11: makeAutoShuffleList
import android.database.Cursor; //导入方法依赖的package包/类
private boolean makeAutoShuffleList() {
Cursor cursor = null;
try {
cursor = getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
new String[]{
MediaStore.Audio.Media._ID
}, MediaStore.Audio.Media.IS_MUSIC + "=1", null, null);
if (cursor == null || cursor.getCount() == 0) {
return false;
}
final int len = cursor.getCount();
final long[] list = new long[len];
for (int i = 0; i < len; i++) {
cursor.moveToNext();
list[i] = cursor.getLong(0);
}
mAutoShuffleList = list;
return true;
} catch (final RuntimeException e) {
} finally {
if (cursor != null) {
cursor.close();
cursor = null;
}
}
return false;
}
示例12: ContentProviderSimpleAdapter
import android.database.Cursor; //导入方法依赖的package包/类
private ContentProviderSimpleAdapter(final Uri baseProvider, Context context) {
String[] projection = {MediaStore.Images.Media._ID};
Cursor cursor = context.getContentResolver()
.query(baseProvider, projection, null, null, null);
final int columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media._ID);
mUris = new Uri[cursor.getCount()];
int i = 0;
while (cursor.moveToNext()) {
final String imageId = cursor.getString(columnIndex);
mUris[i++] = Uri.withAppendedPath(baseProvider, imageId);
}
cursor.close();
}
示例13: setRingtone
import android.database.Cursor; //导入方法依赖的package包/类
public static void setRingtone(AppCompatActivity context, long id) {
if (!checkSystemWritePermission(context)) return;
ContentResolver resolver = context.getContentResolver();
Uri ringUri = ContentUris.withAppendedId(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, id);
try {
ContentValues values = new ContentValues(2);
values.put(MediaStore.Audio.Media.IS_RINGTONE, "1");
values.put(MediaStore.Audio.Media.IS_ALARM, "1");
resolver.update(ringUri, values, null, null);
} catch (UnsupportedOperationException ex) {
Log.e("Notset", "couldn't set ringtone flag for id " + id);
return;
}
String[] cols = new String[]{
MediaStore.Audio.Media._ID,
MediaStore.Audio.Media.DATA,
MediaStore.Audio.Media.TITLE
};
String where = MediaStore.Audio.Media._ID + "=" + id;
Cursor cursor = context.getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
cols, where, null, null);
try {
if (cursor != null && cursor.getCount() == 1) {
cursor.moveToFirst();
Settings.System.putString(resolver, Settings.System.RINGTONE, ringUri.toString());
String message = context.getString(R.string.ringtone_set);
String filename = '"' + cursor.getString(2) + '"';
Toast.makeText(context, filename + " " + message, Toast.LENGTH_SHORT).show();
}
} finally {
if (cursor != null) {
cursor.close();
}
}
}
示例14: cursorToList
import android.database.Cursor; //导入方法依赖的package包/类
static List<App> cursorToList(Cursor cursor) {
int knownAppCount = cursor != null ? cursor.getCount() : 0;
List<App> apps = new ArrayList<>(knownAppCount);
if (cursor != null) {
if (knownAppCount > 0) {
cursor.moveToFirst();
while (!cursor.isAfterLast()) {
apps.add(new App(cursor));
cursor.moveToNext();
}
}
cursor.close();
}
return apps;
}
示例15: getWorldCupTraceNumExceptStatus
import android.database.Cursor; //导入方法依赖的package包/类
public int getWorldCupTraceNumExceptStatus(int status) {
Cursor cursor = null;
try {
cursor = this.context.getContentResolver().query(LetvContentProvider.URI_WORLDCUPTRACE, null, "finish!=?", new String[]{status + ""}, "timestamp ASC");
int count = cursor.getCount();
return count;
} finally {
LetvTools.closeCursor(cursor);
}
}