本文整理汇总了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
);
}
示例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;
}
示例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);
}
示例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();
}
}
示例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
);
}
示例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;
}
}
示例7: size
import android.database.DatabaseUtils; //导入方法依赖的package包/类
static long size(SQLiteDatabase database) {
if (database == null) {
return 0;
}
return DatabaseUtils.queryNumEntries(database, TABLE_NAME);
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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
);
}
示例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;
}