当前位置: 首页>>代码示例>>Java>>正文


Java DatabaseUtils.longForQuery方法代码示例

本文整理汇总了Java中android.database.DatabaseUtils.longForQuery方法的典型用法代码示例。如果您正苦于以下问题:Java DatabaseUtils.longForQuery方法的具体用法?Java DatabaseUtils.longForQuery怎么用?Java DatabaseUtils.longForQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.database.DatabaseUtils的用法示例。


在下文中一共展示了DatabaseUtils.longForQuery方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getUnitId

import android.database.DatabaseUtils; //导入方法依赖的package包/类
public int getUnitId(String languageCode, String slug, String version, int chapter, int startVerse) throws IllegalArgumentException{
//        Logger.w(this.toString(), "Trying to get unit Id for start verse " + startVerse);
        String projectId = String.valueOf(getProjectId(languageCode, slug, version));
        String chapterId = String.valueOf(getChapterId(languageCode, slug, version, chapter));
        SQLiteDatabase db = getReadableDatabase();
        final String unitIdQuery = String.format("SELECT %s FROM %s WHERE %s=? AND %s=? AND %s=?",
                ProjectContract.UnitEntry._ID, ProjectContract.UnitEntry.TABLE_UNIT, ProjectContract.UnitEntry.UNIT_PROJECT_FK, ProjectContract.UnitEntry.UNIT_CHAPTER_FK, ProjectContract.UnitEntry.UNIT_START_VERSE);
        int id = -1;
        try {
            id = (int) DatabaseUtils.longForQuery(db, unitIdQuery, new String[]{projectId, chapterId, String.valueOf(startVerse)});
        } catch (SQLiteDoneException e){
            //db.close();
            throw new IllegalArgumentException("Unit not found in database");
        }
        //db.close();
        return id;
    }
 
开发者ID:WycliffeAssociates,项目名称:translationRecorder,代码行数:18,代码来源:ProjectDatabaseHelper.java

示例2: getProjectId

import android.database.DatabaseUtils; //导入方法依赖的package包/类
public int getProjectId(String languageCode, String slug, String version) throws IllegalArgumentException {
//        Logger.w(this.toString(), "Trying to get project Id for " + languageCode + " " + slug + " " + version);
        String languageId = String.valueOf(getLanguageId(languageCode));
        String bookId = String.valueOf(getBookId(slug));
        SQLiteDatabase db = getReadableDatabase();
        final String projectIdQuery = String.format("SELECT %s FROM %s WHERE %s=? AND %s=? AND %s=?",
                ProjectContract.ProjectEntry._ID, ProjectContract.ProjectEntry.TABLE_PROJECT, ProjectContract.ProjectEntry.PROJECT_TARGET_LANGUAGE_FK, ProjectContract.ProjectEntry.PROJECT_BOOK_FK, ProjectContract.ProjectEntry.PROJECT_VERSION);
        int id = -1;
        try {
            id = (int) DatabaseUtils.longForQuery(db, projectIdQuery, new String[]{languageId, bookId, version});
        } catch (SQLiteDoneException e) {
            //db.close();
            throw new IllegalArgumentException("Project not found in database");
        }
        //db.close();
        return id;
    }
 
开发者ID:WycliffeAssociates,项目名称:translationRecorder,代码行数:18,代码来源:ProjectDatabaseHelper.java

示例3: getBookCategoryId

import android.database.DatabaseUtils; //导入方法依赖的package包/类
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)}
        );

    }
 
开发者ID:fekracomputers,项目名称:IslamicLibraryAndroid,代码行数:14,代码来源:BooksInformationDbHelper.java

示例4: getBookIdByDownloadId

import android.database.DatabaseUtils; //导入方法依赖的package包/类
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)}
    );
}
 
开发者ID:fekracomputers,项目名称:IslamicLibraryAndroid,代码行数:12,代码来源:BooksInformationDbHelper.java

示例5: isDownloadEnqueue

import android.database.DatabaseUtils; //导入方法依赖的package包/类
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)}
    );


}
 
开发者ID:fekracomputers,项目名称:IslamicLibraryAndroid,代码行数:13,代码来源:BooksInformationDbHelper.java

示例6: getTitlePositionUnderParent

import android.database.DatabaseUtils; //导入方法依赖的package包/类
/**
 * @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)});
}
 
开发者ID:fekracomputers,项目名称:IslamicLibraryAndroid,代码行数:15,代码来源:BookDatabaseHelper.java

示例7: isPartPageCombinationValid

import android.database.DatabaseUtils; //导入方法依赖的package包/类
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;
}
 
开发者ID:fekracomputers,项目名称:IslamicLibraryAndroid,代码行数:10,代码来源:BookDatabaseHelper.java

示例8: setMaximumSize

import android.database.DatabaseUtils; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:doppllib,项目名称:core-doppl,代码行数:19,代码来源:SQLiteDatabase.java

示例9: a

import android.database.DatabaseUtils; //导入方法依赖的package包/类
private static void a(Context paramContext, int paramInt, SQLiteDatabase paramSQLiteDatabase, String paramString, long paramLong)
{
  String str = a(paramContext, paramInt);
  ContentValues localContentValues1 = new ContentValues(1);
  localContentValues1.put("cluster_count", Long.valueOf(paramLong));
  paramSQLiteDatabase.update("all_tiles", localContentValues1, "cluster_id = ? AND type = ?", new String[] { paramString, "2" });
  long l1 = DatabaseUtils.longForQuery(paramSQLiteDatabase, "SELECT count(*) FROM all_tiles WHERE type = ? AND view_id = ? AND parent_id = ?", new String[] { "4", str, paramString });
  long l2;
  ContentValues localContentValues2;
  String[] arrayOfString1;
  if (l1 > 0L)
  {
    l2 = paramLong - l1;
    localContentValues2 = new ContentValues(1);
    localContentValues2.put("title", Long.valueOf(l2));
    arrayOfString1 = new String[] { "101", str, paramString };
    if (l2 != 0L) {
      break label164;
    }
    paramSQLiteDatabase.delete("all_tiles", "type = ? AND view_id = ? AND parent_id = ?", arrayOfString1);
  }
  label164:
  while (paramSQLiteDatabase.update("all_tiles", localContentValues2, "type = ? AND view_id = ? AND parent_id = ?", arrayOfString1) != 0) {
    return;
  }
  okn localokn = efj.a(paramString, l2);
  long l3 = 1L + DatabaseUtils.longForQuery(paramSQLiteDatabase, "SELECT view_order FROM all_tiles WHERE view_id = ? AND parent_id = ? ORDER BY view_order DESC limit 1", new String[] { str, paramString });
  String[] arrayOfString2 = new String[2];
  arrayOfString2[0] = str;
  arrayOfString2[1] = String.valueOf(l3);
  paramSQLiteDatabase.execSQL("UPDATE all_tiles SET view_order = view_order + 1 WHERE view_id = ? AND view_order >= ?", arrayOfString2);
  a(paramContext, paramInt, paramSQLiteDatabase, str, new okn[] { localokn }, l3, null, null, null, paramString, new HashSet());
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:34,代码来源:jrf.java

示例10: o

import android.database.DatabaseUtils; //导入方法依赖的package包/类
public final Cursor o()
{
  if (this.r == -1) {
    return null;
  }
  Cursor localCursor = DreamSettingsActivity.a(this.l, aau.iH);
  SQLiteDatabase localSQLiteDatabase = bqj.a(this.l, this.r).getReadableDatabase();
  MatrixCursor localMatrixCursor = new MatrixCursor(DreamSettingsActivity.e);
  if (DatabaseUtils.longForQuery(localSQLiteDatabase, "SELECT count(*) FROM all_photos WHERE is_primary = 1 AND media_attr & 32 = 0 AND media_attr & 128 = 0 AND media_attr & 64 = 0", null) > 0L)
  {
    Object[] arrayOfObject2 = new Object[4];
    arrayOfObject2[0] = Integer.valueOf(0);
    arrayOfObject2[1] = null;
    arrayOfObject2[2] = this.l.getString(aau.fr);
    arrayOfObject2[3] = Integer.valueOf(3);
    localMatrixCursor.addRow(arrayOfObject2);
  }
  String[] arrayOfString = new String[1];
  arrayOfString[0] = this.s;
  String str = jrf.a(0, arrayOfString);
  if (DatabaseUtils.longForQuery(localSQLiteDatabase, "SELECT count(*) FROM all_tiles WHERE view_id = ? AND media_attr & 512 == 0 AND type == 4 AND media_attr & 32 = 0 AND media_attr & 128 = 0 AND media_attr & 64 = 0", new String[] { str }) > 0L)
  {
    Object[] arrayOfObject1 = new Object[4];
    arrayOfObject1[0] = Integer.valueOf(0);
    arrayOfObject1[1] = str;
    arrayOfObject1[2] = this.l.getString(aau.fs);
    arrayOfObject1[3] = Integer.valueOf(2);
    localMatrixCursor.addRow(arrayOfObject1);
  }
  if (DatabaseUtils.longForQuery(localSQLiteDatabase, "SELECT count(*) FROM all_tiles WHERE view_id = ?", this.t) == 0L) {
    new bmt(this.l, this.r, this.s, null, false).i();
  }
  return new MergeCursor(new Cursor[] { localCursor, localMatrixCursor, localSQLiteDatabase.query("all_tiles", DreamSettingsActivity.e, "view_id = ?", this.t, null, null, null) });
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:35,代码来源:dkx.java

示例11: bookExists

import android.database.DatabaseUtils; //导入方法依赖的package包/类
public boolean bookExists(String slug){
    SQLiteDatabase db = getReadableDatabase();
    final String bookCountQuery = "SELECT COUNT(*) FROM " + ProjectContract.BookEntry.TABLE_BOOK + " WHERE " + ProjectContract.BookEntry.BOOK_SLUG + "=?";
    boolean exists = (DatabaseUtils.longForQuery(db, bookCountQuery, new String[]{slug})) > 0;
    //db.close();
    return exists;
}
 
开发者ID:WycliffeAssociates,项目名称:translationRecorder,代码行数:8,代码来源:ProjectDatabaseHelper.java

示例12: d

import android.database.DatabaseUtils; //导入方法依赖的package包/类
public static long d(Context paramContext, int paramInt)
{
  SQLiteDatabase localSQLiteDatabase = bqj.a(paramContext, paramInt).getReadableDatabase();
  try
  {
    long l = DatabaseUtils.longForQuery(localSQLiteDatabase, "SELECT last_contacted_time  FROM account_status", null);
    return l;
  }
  catch (SQLiteDoneException localSQLiteDoneException) {}
  return -1L;
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:12,代码来源:bgp.java

示例13: j

import android.database.DatabaseUtils; //导入方法依赖的package包/类
public static long j(Context paramContext, int paramInt)
{
  efj.l();
  SQLiteDatabase localSQLiteDatabase = ((hci)mbb.a(paramContext, hci.class)).getReadableDatabase();
  if (localSQLiteDatabase == null) {
    return 0L;
  }
  String str1 = MediaRecordEntry.a.a;
  String str2 = String.valueOf("SELECT min(upload_finish_time) FROM ");
  String str3 = String.valueOf("upload_account_id");
  String str4 = 11 + String.valueOf(str2).length() + String.valueOf(str1).length() + String.valueOf(str3).length() + str2 + str1 + " WHERE " + str3 + " = ?";
  String[] arrayOfString = new String[1];
  arrayOfString[0] = Integer.toString(paramInt);
  return (int)DatabaseUtils.longForQuery(localSQLiteDatabase, str4, arrayOfString);
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:16,代码来源:hbj.java

示例14: a

import android.database.DatabaseUtils; //导入方法依赖的package包/类
public static boolean a(Context paramContext, ArrayList<String> paramArrayList)
{
  SQLiteDatabase localSQLiteDatabase = bvd.a(paramContext).getWritableDatabase();
  StringBuilder localStringBuilder = new StringBuilder();
  localStringBuilder.append("SELECT COUNT(*) FROM photos").append(" WHERE ");
  a(localStringBuilder, "fingerprint", paramArrayList);
  localStringBuilder.append(" AND local_path").append(" NOT NULL");
  return 0L < DatabaseUtils.longForQuery(localSQLiteDatabase, localStringBuilder.toString(), null);
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:10,代码来源:bvf.java

示例15: f

import android.database.DatabaseUtils; //导入方法依赖的package包/类
public static long f(Context paramContext, int paramInt)
{
  SQLiteDatabase localSQLiteDatabase = bqj.a(paramContext, paramInt).getReadableDatabase();
  try
  {
    long l = DatabaseUtils.longForQuery(localSQLiteDatabase, "SELECT notification_poll_interval  FROM account_status", null);
    return l;
  }
  catch (SQLiteDoneException localSQLiteDoneException) {}
  return -1L;
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:12,代码来源:brg.java


注:本文中的android.database.DatabaseUtils.longForQuery方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。