Exemplo n.º 1
0
  /**
   * @param context the {@link Context} to use.
   * @return the db.
   * @throws IOException if something goes wrong.
   */
  public SQLiteDatabase getDatabase(Context context) throws IOException {
    File databaseFile;
    try {
      databaseFile = ResourcesManager.getInstance(context).getDatabaseFile();
    } catch (Exception e) {
      throw new IOException(e.getLocalizedMessage());
    }
    if (databaseHelper == null || !databaseFile.exists()) {

      databaseHelper = new DatabaseOpenHelper(databaseFile);

      SQLiteDatabase db = databaseHelper.getWritableDatabase(context);
      if (GPLog.LOG_ANDROID) {
        Log.i(DEBUG_TAG, "Database: " + db.getPath());
        Log.i(DEBUG_TAG, "Database Version: " + db.getVersion());
        Log.i(DEBUG_TAG, "Database Page Size: " + db.getPageSize());
        Log.i(DEBUG_TAG, "Database Max Size: " + db.getMaximumSize());
        Log.i(DEBUG_TAG, "Database Open?  " + db.isOpen());
        Log.i(DEBUG_TAG, "Database readonly?  " + db.isReadOnly());
        Log.i(DEBUG_TAG, "Database Locked by current thread?  " + db.isDbLockedByCurrentThread());
      }
    }

    return databaseHelper.getWritableDatabase(context);
  }
Exemplo n.º 2
0
 public long getTotalQuestionNumber() {
   return db.getMaximumSize();
 }