Java Code Examples for android.database.DatabaseUtils#longForQuery()
The following examples show how to use
android.database.DatabaseUtils#longForQuery() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AccountsDb.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
int calculateDebugTableInsertionPoint() { SQLiteDatabase db = mDeDatabase.getReadableDatabase(); String queryCountDebugDbRows = "SELECT COUNT(*) FROM " + TABLE_DEBUG; int size = (int) DatabaseUtils.longForQuery(db, queryCountDebugDbRows, null); if (size < MAX_DEBUG_DB_SIZE) { return size; } // This query finds the smallest timestamp value (and if 2 records have // same timestamp, the choose the lower id). queryCountDebugDbRows = "SELECT " + DEBUG_TABLE_KEY + " FROM " + TABLE_DEBUG + " ORDER BY " + DEBUG_TABLE_TIMESTAMP + "," + DEBUG_TABLE_KEY + " LIMIT 1"; return (int) DatabaseUtils.longForQuery(db, queryCountDebugDbRows, null); }
Example 2
Source File: FeatureChanges.java From android_maplib with GNU Lesser General Public License v3.0 | 6 votes |
public static long getChangeCount(String tableName) { String selection = getSelectionForSync(); MapContentProviderHelper map = (MapContentProviderHelper) MapBase.getInstance(); SQLiteDatabase db = map.getDatabase(true); try { // From sources of DatabaseUtils.queryNumEntries() String s = (!TextUtils.isEmpty(selection)) ? " where " + selection : ""; return DatabaseUtils.longForQuery(db, "select count(*) from " + tableName + s, null); } catch (SQLiteException e) { e.printStackTrace(); Log.d(TAG, e.getLocalizedMessage()); return 0; } }
Example 3
Source File: AccountsDb.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
long findAccountLastAuthenticatedTime(Account account) { SQLiteDatabase db = mDeDatabase.getReadableDatabase(); return DatabaseUtils.longForQuery(db, "SELECT " + AccountsDb.ACCOUNTS_LAST_AUTHENTICATE_TIME_EPOCH_MILLIS + " FROM " + TABLE_ACCOUNTS + " WHERE " + ACCOUNTS_NAME + "=? AND " + ACCOUNTS_TYPE + "=?", new String[] {account.name, account.type}); }
Example 4
Source File: SQLiteDatabase.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * Sets the maximum size the database will grow to. The maximum size cannot * be set below the current size. * * @param numBytes the maximum database size, in bytes * @return the new maximum database size */ public long setMaximumSize(long numBytes) { long pageSize = getPageSize(); long numPages = numBytes / pageSize; // If numBytes isn't a multiple of pageSize, bump up a page if ((numBytes % pageSize) != 0) { numPages++; } long newPageCount = DatabaseUtils.longForQuery(this, "PRAGMA max_page_count = " + numPages, null); return newPageCount * pageSize; }
Example 5
Source File: AndroidDatabaseDelegate.java From java-unified-sdk with Apache License 2.0 | 5 votes |
public long countForQuery(String query, String[] selectionArgs) { if (StringUtil.isEmpty(query)) { return 0l; } SQLiteDatabase db = dbHelper.getReadableDatabase(); return DatabaseUtils.longForQuery(db, query, selectionArgs); }
Example 6
Source File: BooksInformationDbHelper.java From IslamicLibraryAndroid with GNU General Public License v3.0 | 5 votes |
public int getBookCategoryId(int bookId) { return (int) DatabaseUtils.longForQuery(getReadableDatabase(), " SELECT " + BooksInformationDBContract.BooksCategories.COLUMN_NAME_CATEGORY_ID + " FROM " + BooksInformationDBContract.BooksCategories.TABLE_NAME + " WHERE " + BooksInformationDBContract.BooksCategories.COLUMN_NAME_BOOK_ID + "=?", new String[]{String.valueOf(bookId)} ); }
Example 7
Source File: BooksInformationDbHelper.java From IslamicLibraryAndroid with GNU General Public License v3.0 | 5 votes |
public long getBookIdByDownloadId(long enquId) { return DatabaseUtils.longForQuery(getReadableDatabase(), SQL.SELECT + BooksInformationDBContract.StoredBooks.COLUMN_NAME_BookID + SQL.FROM + BooksInformationDBContract.StoredBooks.TABLE_NAME + SQL.WHERE + BooksInformationDBContract.StoredBooks.COLUMN_NAME_ENQID + "=?", new String[]{Long.toString(enquId)} ); }
Example 8
Source File: BooksInformationDbHelper.java From IslamicLibraryAndroid with GNU General Public License v3.0 | 5 votes |
public boolean isDownloadEnqueue(long enqueueId) { return 1L == DatabaseUtils.longForQuery(getReadableDatabase(), " SELECT COUNT(*)" + " FROM " + BooksInformationDBContract.StoredBooks.TABLE_NAME + " WHERE " + BooksInformationDBContract.StoredBooks.COLUMN_NAME_ENQID + "=?", new String[]{String.valueOf(enqueueId)} ); }
Example 9
Source File: BookDatabaseHelper.java From IslamicLibraryAndroid with GNU General Public License v3.0 | 5 votes |
/** * @param titleId the title id to return its positin * @param parentId * @return the o based position of this title within is parent */ public int getTitlePositionUnderParent(int titleId, int parentId) { return (int) DatabaseUtils.longForQuery(getReadableDatabase(), SQL.SELECT + "count(*)" + SQL.FROM + "(" + SQL.SELECT + " null " + SQL.FROM + BookDatabaseContract.TitlesEntry.TABLE_NAME + SQL.WHERE + BookDatabaseContract.TitlesEntry.COLUMN_NAME_PARENT_ID + "=? and " + BookDatabaseContract.TitlesEntry.COLUMN_NAME_ID + "<? )", new String[]{String.valueOf(parentId), String.valueOf(titleId)}); }
Example 10
Source File: BookDatabaseHelper.java From IslamicLibraryAndroid with GNU General Public License v3.0 | 5 votes |
public boolean isPartPageCombinationValid(int partNumber, int pageNumber) { return DatabaseUtils.longForQuery(getReadableDatabase(), SQL.SELECT + " count(*) " + SQL.FROM + "(" + SQL.SELECT + SQL.NULL + SQL.FROM + BookDatabaseContract.PageEntry.TABLE_NAME + SQL.WHERE + BookDatabaseContract.PageEntry.COLUMN_NAME_PART_NUMBER + "=?" + SQL.AND + BookDatabaseContract.PageEntry.COLUMN_NAME_PAGE_NUMBER + "=?)", new String[]{String.valueOf(partNumber), String.valueOf(pageNumber)}) > 0L; }
Example 11
Source File: AccountsDb.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
long findMatchingGrantsCount(int uid, String authTokenType, Account account) { SQLiteDatabase db = mDeDatabase.getReadableDatabase(); String[] args = {String.valueOf(uid), authTokenType, account.name, account.type}; return DatabaseUtils.longForQuery(db, COUNT_OF_MATCHING_GRANTS, args); }
Example 12
Source File: AccountsDb.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
long findMatchingGrantsCountAnyToken(int uid, Account account) { SQLiteDatabase db = mDeDatabase.getReadableDatabase(); String[] args = {String.valueOf(uid), account.name, account.type}; return DatabaseUtils.longForQuery(db, COUNT_OF_MATCHING_GRANTS_ANY_TOKEN, args); }
Example 13
Source File: AndroidSql.java From Android_Code_Arbiter with GNU Lesser General Public License v3.0 | 4 votes |
public void sampleDatabaseUtils(DatabaseUtils databaseUtils, String input) { databaseUtils.longForQuery(null, input, null); databaseUtils.stringForQuery(null, input, null); databaseUtils.blobFileDescriptorForQuery(null, input, null); databaseUtils.createDbFromSqlStatements(null, null, 0, input); }
Example 14
Source File: DbAdapter.java From Onosendai with Apache License 2.0 | 4 votes |
@Override public long getTotalTweetsEverSeen () { return DatabaseUtils.longForQuery(this.mDb, "SELECT max(" + TBL_TW_ID + ") FROM " + TBL_TW, null); }
Example 15
Source File: SQLiteDatabase.java From android_9.0.0_r45 with Apache License 2.0 | 2 votes |
/** * Returns the maximum size the database may grow to. * * @return the new maximum database size */ public long getMaximumSize() { long pageCount = DatabaseUtils.longForQuery(this, "PRAGMA max_page_count;", null); return pageCount * getPageSize(); }
Example 16
Source File: SQLiteDatabase.java From android_9.0.0_r45 with Apache License 2.0 | 2 votes |
/** * Returns the current database page size, in bytes. * * @return the database page size, in bytes */ public long getPageSize() { return DatabaseUtils.longForQuery(this, "PRAGMA page_size;", null); }