当前位置: 首页>>代码示例>>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;未经允许,请勿转载。