當前位置: 首頁>>代碼示例>>Java>>正文


Java Cursor.getCount方法代碼示例

本文整理匯總了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;
}
 
開發者ID:cahergil,項目名稱:Farmacias,代碼行數:17,代碼來源:FindPresenter.java

示例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;
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:21,代碼來源:SQLiteHandle.java

示例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;
}
 
開發者ID:fekracomputers,項目名稱:IslamicLibraryAndroid,代碼行數:23,代碼來源:AuthorRecyclerViewAdapter.java

示例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();
        }
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:19,代碼來源:DownloadManager.java

示例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;
}
 
開發者ID:5GSD,項目名稱:AIMSICDL,代碼行數:15,代碼來源:AIMSICDDbAdapter.java

示例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;
}
 
開發者ID:pooyafaroka,項目名稱:PlusGram,代碼行數:28,代碼來源:userDBAdapter.java

示例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;
    }
}
 
開發者ID:robsonribeiroft,項目名稱:nucleus-test,代碼行數:12,代碼來源:UserDAO.java

示例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;
}
 
開發者ID:Loofer,項目名稱:Watermark,代碼行數:37,代碼來源:MediaUtils.java

示例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;
}
 
開發者ID:archos-sa,項目名稱:aos-MediaLib,代碼行數:30,代碼來源:MusicStoreImportImpl.java

示例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;
}
 
開發者ID:uhuru-mobile,項目名稱:mobile-store,代碼行數:12,代碼來源:RepoProvider.java

示例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;
}
 
開發者ID:Vinetos,項目名稱:Hello-Music-droid,代碼行數:28,代碼來源:MusicService.java

示例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();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:14,代碼來源:ContentProviderSimpleAdapter.java

示例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();
        }
    }
}
 
開發者ID:reyanshmishra,項目名稱:Rey-MusicPlayer,代碼行數:40,代碼來源:MusicUtils.java

示例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;
}
 
開發者ID:uhuru-mobile,項目名稱:mobile-store,代碼行數:16,代碼來源:AppProvider.java

示例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);
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:11,代碼來源:WorldCupTraceHandler.java


注:本文中的android.database.Cursor.getCount方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。