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


Java DatabaseUtils.queryNumEntries方法代碼示例

本文整理匯總了Java中android.database.DatabaseUtils.queryNumEntries方法的典型用法代碼示例。如果您正苦於以下問題:Java DatabaseUtils.queryNumEntries方法的具體用法?Java DatabaseUtils.queryNumEntries怎麽用?Java DatabaseUtils.queryNumEntries使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.database.DatabaseUtils的用法示例。


在下文中一共展示了DatabaseUtils.queryNumEntries方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: numTrustedKeys

import android.database.DatabaseUtils; //導入方法依賴的package包/類
public long numTrustedKeys(Account account, String name) {
	SQLiteDatabase db = getReadableDatabase();
	String[] args = {
			account.getUuid(),
			name,
			FingerprintStatus.Trust.TRUSTED.toString(),
			FingerprintStatus.Trust.VERIFIED.toString(),
			FingerprintStatus.Trust.VERIFIED_X509.toString()
	};
	return DatabaseUtils.queryNumEntries(db, SQLiteAxolotlStore.IDENTITIES_TABLENAME,
			SQLiteAxolotlStore.ACCOUNT + " = ?"
					+ " AND " + SQLiteAxolotlStore.NAME + " = ?"
					+ " AND (" + SQLiteAxolotlStore.TRUST + " = ? OR " + SQLiteAxolotlStore.TRUST + " = ? OR " +SQLiteAxolotlStore.TRUST +" = ?)"
					+ " AND " +SQLiteAxolotlStore.ACTIVE + " > 0",
			args
	);
}
 
開發者ID:syntafin,項目名稱:TenguChat,代碼行數:18,代碼來源:DatabaseBackend.java

示例2: addAccessToken

import android.database.DatabaseUtils; //導入方法依賴的package包/類
public long addAccessToken(AccessToken accessToken){
    SQLiteDatabase database=getWritableDatabase();

    ContentValues contentValues = new ContentValues();
    contentValues.put("type", accessToken.getType());
    contentValues.put("url", accessToken.getUrl());
    contentValues.put("userName", accessToken.getScreenName());
    contentValues.put("userId", String.valueOf(accessToken.getUserId()));
    contentValues.put("token", accessToken.getToken());
    contentValues.put("tokenSecret", accessToken.getTokenSecret());

    database.replace("AccountTokenList", null, contentValues);

    long count = DatabaseUtils.queryNumEntries(database,"AccountTokenList");
    database.close();
    return count;
}
 
開發者ID:moko256,項目名稱:twicalico,代碼行數:18,代碼來源:TokenSQLiteOpenHelper.java

示例3: insertReview

import android.database.DatabaseUtils; //導入方法依賴的package包/類
private static boolean insertReview(SQLiteDatabase db, ContentValues reviewValues) {
    final long rowId;
    // Wrapped both inserts as a SQL transaction as a precaution.
    db.beginTransaction();
    try {
        rowId = db.insert(GOOGLE_PLAY_REVIEW, null, reviewValues);
        long count = DatabaseUtils.queryNumEntries(db, GOOGLE_PLAY_REVIEW);
        Log.i("Review added", "Row ID: [" + rowId + "] Count now: " + count);
        if (rowId != -1) {
            ContentValues statusValues = new ContentValues();
            statusValues.put(REVIEW_ID, rowId);
            statusValues.put(STATUS, ReviewStatus.INITIAL.toString());
            final long rowIdForStatus = db.insert(REVIEW_STATUS, null, statusValues);
        }
        db.setTransactionSuccessful();

    } finally {
        db.endTransaction();
    }
    return (rowId != -1);
}
 
開發者ID:julianharty,項目名稱:app-store-reviews-app,代碼行數:22,代碼來源:ReviewsDatabaseHelper.java

示例4: a

import android.database.DatabaseUtils; //導入方法依賴的package包/類
private final boolean a(int paramInt, ContentValues paramContentValues)
{
  SQLiteDatabase localSQLiteDatabase = hsb.a(this.a, paramInt);
  localSQLiteDatabase.beginTransaction();
  try
  {
    if ((localSQLiteDatabase.update(this.b, paramContentValues, null, null) == 0) && (DatabaseUtils.queryNumEntries(localSQLiteDatabase, this.b) == 0L))
    {
      long l = localSQLiteDatabase.insert(this.b, null, paramContentValues);
      if (l == -1L) {
        return false;
      }
    }
    localSQLiteDatabase.setTransactionSuccessful();
    return true;
  }
  finally
  {
    localSQLiteDatabase.endTransaction();
  }
}
 
開發者ID:ChiangC,項目名稱:FMTech,代碼行數:22,代碼來源:kzl.java

示例5: numTrustedKeys

import android.database.DatabaseUtils; //導入方法依賴的package包/類
public long numTrustedKeys(Account account, String name) {
    SQLiteDatabase db = getReadableDatabase();
    String[] args = {
            account.getUuid(),
            name,
            FingerprintStatus.Trust.TRUSTED.toString(),
            FingerprintStatus.Trust.VERIFIED.toString(),
            FingerprintStatus.Trust.VERIFIED_X509.toString()
    };
    return DatabaseUtils.queryNumEntries(db, SQLiteAxolotlStore.IDENTITIES_TABLENAME,
            SQLiteAxolotlStore.ACCOUNT + " = ?"
                    + " AND " + SQLiteAxolotlStore.NAME + " = ?"
                    + " AND (" + SQLiteAxolotlStore.TRUST + " = ? OR " + SQLiteAxolotlStore.TRUST + " = ? OR " + SQLiteAxolotlStore.TRUST + " = ?)"
                    + " AND " + SQLiteAxolotlStore.ACTIVE + " > 0",
            args
    );
}
 
開發者ID:kriztan,項目名稱:Pix-Art-Messenger,代碼行數:18,代碼來源:DatabaseBackend.java

示例6: insertOrUpdate

import android.database.DatabaseUtils; //導入方法依賴的package包/類
/**
 * Tries to insert the values. If it fails because the item already exists it tries to update
 * the item.
 *
 * @param sqlDb                  database to work with. has to be writable
 * @param table                  the table to insert
 * @param selection              selection to detect a already inserted item
 * @param selectionArgs          keys of the contentValues. there values will be used as the
 *                               selectionArgs for the param selection
 * @param values                 the values to insert
 * @param excludeFieldsForUpdate contentValues keys which should be deleted before the update
 * @return 1 for insert, 0 for update and -1 if something goes wrong
 */
public static int insertOrUpdate(@Nullable SQLiteDatabase sqlDb, String table,
        @Nullable String selection, String[] selectionArgs, @NonNull final ContentValues values,
        @Nullable final String[] excludeFieldsForUpdate) {
    if (sqlDb == null) {
        return -1;
    }

    final long items = DatabaseUtils.queryNumEntries(sqlDb, table, selection, selectionArgs);

    if (items == 0) {
        // insert, item doesn't exist
        final long row = sqlDb.insert(table, null, values);
        if (row == -1) {
            // unknown error
            return -1;
        }
        // success, inserted
        return 1;
    } else {
        // update existing item

        if (excludeFieldsForUpdate != null) {
            for (String excludeField : excludeFieldsForUpdate) {
                values.remove(excludeField);
            }
        }

        sqlDb.update(table, values, selection, selectionArgs);

        // handling the update error is not needed. All possible errors are thrown by the
        // DatabaseUtils.queryNumEntries() (which uses the same params).
        // a wrong selection results only in an insert. update will never called then.
        return 0;
    }
}
 
開發者ID:sfilmak,項目名稱:MakiLite,代碼行數:49,代碼來源:SqliteHelper.java

示例7: size

import android.database.DatabaseUtils; //導入方法依賴的package包/類
static long size(SQLiteDatabase database) {
    if (database == null) {
        return 0;
    }

    return DatabaseUtils.queryNumEntries(database, TABLE_NAME);
}
 
開發者ID:OpenLocate,項目名稱:openlocate-android,代碼行數:8,代碼來源:LocationTable.java

示例8: getEventsCount

import android.database.DatabaseUtils; //導入方法依賴的package包/類
/**
 * Gets number of rows in the event table.
 *
 * @return Number of rows in the event table.
 */
static long getEventsCount() {
  long count = 0;
  if (database == null) {
    return count;
  }
  try {
    count = DatabaseUtils.queryNumEntries(database, EVENT_TABLE_NAME);
    willSendErrorLog = false;
  } catch (Throwable t) {
    handleSQLiteError("Unable to get a number of rows in the table.", t);
  }
  return count;
}
 
開發者ID:Leanplum,項目名稱:Leanplum-Android-SDK,代碼行數:19,代碼來源:LeanplumEventDataManager.java

示例9: getUpdatedPostCount

import android.database.DatabaseUtils; //導入方法依賴的package包/類
@Override
public long getUpdatedPostCount() throws DatabaseException {
    try {
        String selection = PostEntry.COLUMN_NAME_IS_UPDATED + " = 1 AND " + PostEntry.COLUMN_NAME_IS_READ + " = 1";
        return DatabaseUtils.queryNumEntries(database, PostEntry.TABLE_NAME, selection);
    }
    catch(SQLException e) {
        throw new DatabaseException(e);
    }
}
 
開發者ID:tbolender,項目名稱:fefereader,代碼行數:11,代碼來源:SQLiteWrapper.java

示例10: getUnreadPostCount

import android.database.DatabaseUtils; //導入方法依賴的package包/類
@Override
public long getUnreadPostCount() throws DatabaseException {
    try {
        String selection = PostEntry.COLUMN_NAME_IS_READ + " = 0";
        return DatabaseUtils.queryNumEntries(database, PostEntry.TABLE_NAME, selection);
    }
    catch(SQLException e) {
        throw new DatabaseException(e);
    }
}
 
開發者ID:tbolender,項目名稱:fefereader,代碼行數:11,代碼來源:SQLiteWrapper.java

示例11: e

import android.database.DatabaseUtils; //導入方法依賴的package包/類
private void e() {
    try {
        ContentValues contentValues = new ContentValues();
        contentValues.put("status", Integer.valueOf(1));
        this.d.getWritableDatabase().update("events", contentValues, "status=?", new
                String[]{Long.toString(2)});
        this.b = (int) DatabaseUtils.queryNumEntries(this.d.getReadableDatabase(), "events");
        e.i("Total " + this.b + " unsent events.");
    } catch (Object th) {
        e.e(th);
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:13,代碼來源:n.java

示例12: getUnreadCount

import android.database.DatabaseUtils; //導入方法依賴的package包/類
public long getUnreadCount(){
    SQLiteDatabase db = getWritableDatabase();
    if(db != null){
        return DatabaseUtils.queryNumEntries(db, TABLE, COL_READ + "=" + FALSE);
    }
    return  0;
}
 
開發者ID:casific,項目名稱:murmur,代碼行數:8,代碼來源:MessageStore.java

示例13: deleteAccessToken

import android.database.DatabaseUtils; //導入方法依賴的package包/類
public long deleteAccessToken(long userId){
    SQLiteDatabase database=getWritableDatabase();
    database.delete("AccountTokenList", "userId=" + String.valueOf(userId), null);
    long count = DatabaseUtils.queryNumEntries(database,"AccountTokenList");
    database.close();
    return count;
}
 
開發者ID:moko256,項目名稱:twicalico,代碼行數:8,代碼來源:TokenSQLiteOpenHelper.java

示例14: numTrustedKeys

import android.database.DatabaseUtils; //導入方法依賴的package包/類
public long numTrustedKeys(Account account, String name) {
	SQLiteDatabase db = getReadableDatabase();
	String[] args = {
			account.getUuid(),
			name,
			String.valueOf(XmppAxolotlSession.Trust.TRUSTED.getCode()),
			String.valueOf(XmppAxolotlSession.Trust.TRUSTED_X509.getCode())
	};
	return DatabaseUtils.queryNumEntries(db, SQLiteAxolotlStore.IDENTITIES_TABLENAME,
			SQLiteAxolotlStore.ACCOUNT + " = ?"
					+ " AND " + SQLiteAxolotlStore.NAME + " = ?"
					+ " AND (" + SQLiteAxolotlStore.TRUSTED + " = ? OR " + SQLiteAxolotlStore.TRUSTED + " = ?)",
			args
	);
}
 
開發者ID:xavierle,項目名稱:messengerxmpp,代碼行數:16,代碼來源:DatabaseBackend.java

示例15: size

import android.database.DatabaseUtils; //導入方法依賴的package包/類
/**
 * Get size of the queue.
 * @return size of the queue.
 */
public long size() {
  if (cachedCount == null) {
    cachedCount = DatabaseUtils.queryNumEntries(db, TABLE_NAME);
  }

  return cachedCount;
}
 
開發者ID:sematext,項目名稱:sematext-logsene-android,代碼行數:12,代碼來源:SqliteObjectQueue.java


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