android.database.sqlite.SQLiteOpenHelper Java Examples

The following examples show how to use android.database.sqlite.SQLiteOpenHelper. 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: HistoryManager.java    From reacteu-app with MIT License 7 votes vote down vote up
public void deleteHistoryItem(int number) {
  SQLiteOpenHelper helper = new DBHelper(activity);
  SQLiteDatabase db = null;
  Cursor cursor = null;
  try {
    db = helper.getWritableDatabase();      
    cursor = db.query(DBHelper.TABLE_NAME,
                      ID_COL_PROJECTION,
                      null, null, null, null,
                      DBHelper.TIMESTAMP_COL + " DESC");
    cursor.move(number + 1);
    db.delete(DBHelper.TABLE_NAME, DBHelper.ID_COL + '=' + cursor.getString(0), null);
  } finally {
    close(cursor, db);
  }
}
 
Example #2
Source File: HistoryManager.java    From weex with Apache License 2.0 6 votes vote down vote up
public HistoryItem buildHistoryItem(int number) {
  SQLiteOpenHelper helper = new DBHelper(activity);
  SQLiteDatabase db = null;
  Cursor cursor = null;
  try {
    db = helper.getReadableDatabase();
    cursor = db.query(DBHelper.TABLE_NAME, COLUMNS, null, null, null, null, DBHelper.TIMESTAMP_COL + " DESC");
    cursor.move(number + 1);
    String text = cursor.getString(0);
    String display = cursor.getString(1);
    String format = cursor.getString(2);
    long timestamp = cursor.getLong(3);
    String details = cursor.getString(4);
    Result result = new Result(text, null, null, BarcodeFormat.valueOf(format), timestamp);
    return new HistoryItem(result, display, details);
  } finally {
    close(cursor, db);
  }
}
 
Example #3
Source File: HistoryManager.java    From incubator-weex-playground with Apache License 2.0 6 votes vote down vote up
public void deleteHistoryItem(int number) {
  SQLiteOpenHelper helper = new DBHelper(activity);
  SQLiteDatabase db = null;
  Cursor cursor = null;
  try {
    db = helper.getWritableDatabase();      
    cursor = db.query(DBHelper.TABLE_NAME,
                      ID_COL_PROJECTION,
                      null, null, null, null,
                      DBHelper.TIMESTAMP_COL + " DESC");
    cursor.move(number + 1);
    db.delete(DBHelper.TABLE_NAME, DBHelper.ID_COL + '=' + cursor.getString(0), null);
  } finally {
    close(cursor, db);
  }
}
 
Example #4
Source File: HistoryManager.java    From incubator-weex-playground with Apache License 2.0 6 votes vote down vote up
public void trimHistory() {
  SQLiteOpenHelper helper = new DBHelper(activity);
  SQLiteDatabase db = null;
  Cursor cursor = null;
  try {
    db = helper.getWritableDatabase();      
    cursor = db.query(DBHelper.TABLE_NAME,
                      ID_COL_PROJECTION,
                      null, null, null, null,
                      DBHelper.TIMESTAMP_COL + " DESC");
    cursor.move(MAX_ITEMS);
    while (cursor.moveToNext()) {
      String id = cursor.getString(0);
      Log.i(TAG, "Deleting scan history ID " + id);
      db.delete(DBHelper.TABLE_NAME, DBHelper.ID_COL + '=' + id, null);
    }
  } catch (SQLiteException sqle) {
    // We're seeing an error here when called in CaptureActivity.onCreate() in rare cases
    // and don't understand it. First theory is that it's transient so can be safely ignored.
    Log.w(TAG, sqle);
    // continue
  } finally {
    close(cursor, db);
  }
}
 
Example #5
Source File: HistoryManager.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 6 votes vote down vote up
public HistoryItem buildHistoryItem(int number) {
  SQLiteOpenHelper helper = new DBHelper(activity);
  SQLiteDatabase db = null;
  Cursor cursor = null;
  try {
    db = helper.getReadableDatabase();
    cursor = db.query(DBHelper.TABLE_NAME, COLUMNS, null, null, null, null, DBHelper.TIMESTAMP_COL + " DESC");
    cursor.move(number + 1);
    String text = cursor.getString(0);
    String display = cursor.getString(1);
    String format = cursor.getString(2);
    long timestamp = cursor.getLong(3);
    String details = cursor.getString(4);
    Result result = new Result(text, null, null, BarcodeFormat.valueOf(format), timestamp);
    return new HistoryItem(result, display, details);
  } finally {
    close(cursor, db);
  }
}
 
Example #6
Source File: OfflineVideoManager.java    From android-viewer-for-khan-academy with GNU General Public License v3.0 6 votes vote down vote up
public int getDownloadCountForTopic(SQLiteOpenHelper dbh, String topicId, int depth) {
	Log.d(LOG_TAG, "getDownloadCountForTopic");
	
	int result = 0;
	SQLiteDatabase db = dbh.getReadableDatabase();
	
	for (int i = 0; i < depth; ++i) {
		String sql = buildDownloadCountQuery(i);
		Cursor c = db.rawQuery(sql, new String[] {topicId});
		c.moveToFirst();
		result += c.getInt(0);
		Log.d(LOG_TAG, " result is " + result);
		c.close();
	}
	
	return result;
}
 
Example #7
Source File: HistoryManager.java    From barcodescanner-lib-aar with MIT License 6 votes vote down vote up
public HistoryItem buildHistoryItem(int number) {
  SQLiteOpenHelper helper = new DBHelper(activity);
  SQLiteDatabase db = null;
  Cursor cursor = null;
  try {
    db = helper.getReadableDatabase();
    cursor = db.query(DBHelper.TABLE_NAME, COLUMNS, null, null, null, null, DBHelper.TIMESTAMP_COL + " DESC");
    cursor.move(number + 1);
    String text = cursor.getString(0);
    String display = cursor.getString(1);
    String format = cursor.getString(2);
    long timestamp = cursor.getLong(3);
    String details = cursor.getString(4);
    Result result = new Result(text, null, null, BarcodeFormat.valueOf(format), timestamp);
    return new HistoryItem(result, display, details);
  } finally {
    close(cursor, db);
  }
}
 
Example #8
Source File: HistoryManager.java    From reacteu-app with MIT License 6 votes vote down vote up
public void trimHistory() {
  SQLiteOpenHelper helper = new DBHelper(activity);
  SQLiteDatabase db = null;
  Cursor cursor = null;
  try {
    db = helper.getWritableDatabase();      
    cursor = db.query(DBHelper.TABLE_NAME,
                      ID_COL_PROJECTION,
                      null, null, null, null,
                      DBHelper.TIMESTAMP_COL + " DESC");
    cursor.move(MAX_ITEMS);
    while (cursor.moveToNext()) {
      db.delete(DBHelper.TABLE_NAME, DBHelper.ID_COL + '=' + cursor.getString(0), null);
    }
  } catch (SQLiteException sqle) {
    // We're seeing an error here when called in CaptureActivity.onCreate() in rare cases
    // and don't understand it. First theory is that it's transient so can be safely ignored.
    // TODO revisit this after live in a future version to see if it 'worked'
    Log.w(TAG, sqle);
    // continue
  } finally {
    close(cursor, db);
  }
}
 
Example #9
Source File: SQLiteCursorLoader.java    From itracing2 with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected Void doInBackground(Object... params)
{
    SQLiteOpenHelper db = (SQLiteOpenHelper) params[0];
    String table = (String) params[1];
    ContentValues values = (ContentValues) params[2];
    String where = (String) params[3];
    String[] whereParams = (String[]) params[4];

    db.getWritableDatabase()
            .update(table, values, where, whereParams);

    return (null);
}
 
Example #10
Source File: HistoryManager.java    From android-apps with MIT License 5 votes vote down vote up
void clearHistory() {
  SQLiteOpenHelper helper = new DBHelper(activity);
  SQLiteDatabase db = null;
  try {
    db = helper.getWritableDatabase();      
    db.delete(DBHelper.TABLE_NAME, null, null);
  } finally {
    close(null, db);
  }
}
 
Example #11
Source File: HistoryManager.java    From ZXing-Standalone-library with Apache License 2.0 5 votes vote down vote up
/**
 * <p>Builds a text representation of the scanning history. Each scan is encoded on one
 * line, terminated by a line break (\r\n). The values in each line are comma-separated,
 * and double-quoted. Double-quotes within values are escaped with a sequence of two
 * double-quotes. The fields output are:</p>
 *
 * <ol>
 *  <li>Raw text</li>
 *  <li>Display text</li>
 *  <li>Format (e.g. QR_CODE)</li>
 *  <li>Unix timestamp (milliseconds since the epoch)</li>
 *  <li>Formatted version of timestamp</li>
 *  <li>Supplemental info (e.g. price info for a product barcode)</li>
 * </ol>
 */
CharSequence buildHistory() {
  SQLiteOpenHelper helper = new DBHelper(activity);
  SQLiteDatabase db = null;
  Cursor cursor = null;
  try {
    db = helper.getWritableDatabase();
    cursor = db.query(DBHelper.TABLE_NAME,
                      COLUMNS,
                      null, null, null, null,
                      DBHelper.TIMESTAMP_COL + " DESC");

    DateFormat format = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM);
    StringBuilder historyText = new StringBuilder(1000);
    while (cursor.moveToNext()) {

      historyText.append('"').append(massageHistoryField(cursor.getString(0))).append("\",");
      historyText.append('"').append(massageHistoryField(cursor.getString(1))).append("\",");
      historyText.append('"').append(massageHistoryField(cursor.getString(2))).append("\",");
      historyText.append('"').append(massageHistoryField(cursor.getString(3))).append("\",");

      // Add timestamp again, formatted
      long timestamp = cursor.getLong(3);
      historyText.append('"').append(massageHistoryField(
          format.format(new Date(timestamp)))).append("\",");

      // Above we're preserving the old ordering of columns which had formatted data in position 5

      historyText.append('"').append(massageHistoryField(cursor.getString(4))).append("\"\r\n");
    }
    return historyText;
  } finally {
    close(cursor, db);
  }
}
 
Example #12
Source File: DbModule.java    From storio with Apache License 2.0 5 votes vote down vote up
@Provides
@NonNull
@Singleton
public StorIOSQLite provideStorIOSQLite(@NonNull SQLiteOpenHelper sqLiteOpenHelper) {
    final CarStorIOSQLitePutResolver carStorIOSQLitePutResolver = new CarStorIOSQLitePutResolver();
    final CarStorIOSQLiteGetResolver carStorIOSQLiteGetResolver = new CarStorIOSQLiteGetResolver();

    final PersonStorIOSQLitePutResolver personStorIOSQLitePutResolver = new PersonStorIOSQLitePutResolver();
    final PersonStorIOSQLiteGetResolver personStorIOSQLiteGetResolver = new PersonStorIOSQLiteGetResolver();

    final CarPersonRelationPutResolver carPersonRelationPutResolver = new CarPersonRelationPutResolver();

    return DefaultStorIOSQLite.builder()
            .sqliteOpenHelper(sqLiteOpenHelper)
            .addTypeMapping(Tweet.class, new TweetSQLiteTypeMapping())
            .addTypeMapping(User.class, new UserSQLiteTypeMapping())
            .addTypeMapping(TweetWithUser.class, SQLiteTypeMapping.<TweetWithUser>builder()
                    .putResolver(new TweetWithUserPutResolver())
                    .getResolver(new TweetWithUserGetResolver())
                    .deleteResolver(new TweetWithUserDeleteResolver())
                    .build())

            .addTypeMapping(Person.class, SQLiteTypeMapping.<Person>builder()
                    .putResolver(new PersonRelationsPutResolver(carStorIOSQLitePutResolver, carPersonRelationPutResolver))
                    .getResolver(new PersonRelationsGetResolver(carStorIOSQLiteGetResolver))
                    .deleteResolver(new PersonRelationsDeleteResolver())
                    .build())
            .addTypeMapping(Car.class, SQLiteTypeMapping.<Car>builder()
                    .putResolver(new CarRelationsPutResolver(personStorIOSQLitePutResolver, carPersonRelationPutResolver))
                    .getResolver(new CarRelationsGetResolver(personStorIOSQLiteGetResolver))
                    .deleteResolver(new CarRelationsDeleteResolver())

                    .build()
            )
            .build();
}
 
Example #13
Source File: Example2.java    From AnDevCon-RxPatterns with Apache License 2.0 5 votes vote down vote up
public StorIOSQLite provideStorIOSQLite(@NonNull SQLiteOpenHelper sqLiteOpenHelper) {
    return DefaultStorIOSQLite.builder()
            .sqliteOpenHelper(sqLiteOpenHelper)
            // ItemSQLiteTypeMapping is auto-generated at compile-time by StorIO
            .addTypeMapping(Item.class, new ItemSQLiteTypeMapping())
            .build();
}
 
Example #14
Source File: HistoryManager.java    From weex with Apache License 2.0 5 votes vote down vote up
public void addHistoryItem(Result result, ResultHandler handler) {
  // Do not save this item to the history if the preference is turned off, or the contents are
  // considered secure.
  if (!activity.getIntent().getBooleanExtra(Intents.Scan.SAVE_HISTORY, true) ||
      handler.areContentsSecure() || !enableHistory) {
    return;
  }

  SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
  if (!prefs.getBoolean(PreferencesActivity.KEY_REMEMBER_DUPLICATES, false)) {
    deletePrevious(result.getText());
  }

  ContentValues values = new ContentValues();
  values.put(DBHelper.TEXT_COL, result.getText());
  values.put(DBHelper.FORMAT_COL, result.getBarcodeFormat().toString());
  values.put(DBHelper.DISPLAY_COL, handler.getDisplayContents().toString());
  values.put(DBHelper.TIMESTAMP_COL, System.currentTimeMillis());

  SQLiteOpenHelper helper = new DBHelper(activity);
  SQLiteDatabase db = null;
  try {
    db = helper.getWritableDatabase();      
    // Insert the new entry into the DB.
    db.insert(DBHelper.TABLE_NAME, DBHelper.TIMESTAMP_COL, values);
  } finally {
    close(null, db);
  }
}
 
Example #15
Source File: HistoryManager.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 5 votes vote down vote up
void clearHistory() {
  SQLiteOpenHelper helper = new DBHelper(activity);
  SQLiteDatabase db = null;
  try {
    db = helper.getWritableDatabase();      
    db.delete(DBHelper.TABLE_NAME, null, null);
  } finally {
    close(null, db);
  }
}
 
Example #16
Source File: DefaultStorIOSQLiteTest.java    From storio with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void instantiateGetCursor() {
    DefaultStorIOSQLite.builder()
            .sqliteOpenHelper(mock(SQLiteOpenHelper.class))
            .build()
            .get()
            .cursor()
            .withQuery(Query.builder()
                    .table("test_table")
                    .build())
            .withGetResolver(mock(GetResolver.class))
            .prepare();
}
 
Example #17
Source File: HistoryManager.java    From android-apps with MIT License 5 votes vote down vote up
public boolean hasHistoryItems() {
  SQLiteOpenHelper helper = new DBHelper(activity);
  SQLiteDatabase db = null;
  Cursor cursor = null;
  try {
    db = helper.getReadableDatabase();
    cursor = db.query(DBHelper.TABLE_NAME, COUNT_COLUMN, null, null, null, null, null);
    cursor.moveToFirst();
    return cursor.getInt(0) > 0;
  } finally {
    close(cursor, db);
  }
}
 
Example #18
Source File: DefaultStorIOSQLiteTest.java    From storio with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void instantiateGetListOfObjects() {
    DefaultStorIOSQLite.builder()
            .sqliteOpenHelper(mock(SQLiteOpenHelper.class))
            .build()
            .get()
            .listOfObjects(Object.class)
            .withQuery(Query.builder()
                    .table("test_table")
                    .build())
            .withGetResolver(mock(GetResolver.class))
            .prepare();
}
 
Example #19
Source File: HistoryManager.java    From reacteu-app with MIT License 5 votes vote down vote up
private void deletePrevious(String text) {
  SQLiteOpenHelper helper = new DBHelper(activity);
  SQLiteDatabase db = null;
  try {
    db = helper.getWritableDatabase();      
    db.delete(DBHelper.TABLE_NAME, DBHelper.TEXT_COL + "=?", new String[] { text });
  } finally {
    close(null, db);
  }
}
 
Example #20
Source File: HistoryManager.java    From ZXing-Standalone-library with Apache License 2.0 5 votes vote down vote up
public void addHistoryItem(Result result, ResultHandler handler) {
  // Do not save this item to the history if the preference is turned off, or the contents are
  // considered secure.
  if (!activity.getIntent().getBooleanExtra(Intents.Scan.SAVE_HISTORY, true) ||
      handler.areContentsSecure() || !enableHistory) {
    return;
  }

  SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
  if (!prefs.getBoolean(PreferencesActivity.KEY_REMEMBER_DUPLICATES, false)) {
    deletePrevious(result.getText());
  }

  ContentValues values = new ContentValues();
  values.put(DBHelper.TEXT_COL, result.getText());
  values.put(DBHelper.FORMAT_COL, result.getBarcodeFormat().toString());
  values.put(DBHelper.DISPLAY_COL, handler.getDisplayContents().toString());
  values.put(DBHelper.TIMESTAMP_COL, System.currentTimeMillis());

  SQLiteOpenHelper helper = new DBHelper(activity);
  SQLiteDatabase db = null;
  try {
    db = helper.getWritableDatabase();      
    // Insert the new entry into the DB.
    db.insert(DBHelper.TABLE_NAME, DBHelper.TIMESTAMP_COL, values);
  } finally {
    close(null, db);
  }
}
 
Example #21
Source File: DefaultStorIOSQLiteTest.java    From storio with Apache License 2.0 5 votes vote down vote up
@Test
public void instantiateWithoutRxJava() {
    // Should not fail
    DefaultStorIOSQLite.builder()
            .sqliteOpenHelper(mock(SQLiteOpenHelper.class))
            .build();
}
 
Example #22
Source File: HistoryManager.java    From android-apps with MIT License 5 votes vote down vote up
/**
 * <p>Builds a text representation of the scanning history. Each scan is encoded on one
 * line, terminated by a line break (\r\n). The values in each line are comma-separated,
 * and double-quoted. Double-quotes within values are escaped with a sequence of two
 * double-quotes. The fields output are:</p>
 *
 * <ul>
 *  <li>Raw text</li>
 *  <li>Display text</li>
 *  <li>Format (e.g. QR_CODE)</li>
 *  <li>Timestamp</li>
 *  <li>Formatted version of timestamp</li>
 * </ul>
 */
CharSequence buildHistory() {
  StringBuilder historyText = new StringBuilder(1000);
  SQLiteOpenHelper helper = new DBHelper(activity);
  SQLiteDatabase db = null;
  Cursor cursor = null;
  try {
    db = helper.getWritableDatabase();
    cursor = db.query(DBHelper.TABLE_NAME,
                      COLUMNS,
                      null, null, null, null,
                      DBHelper.TIMESTAMP_COL + " DESC");

    while (cursor.moveToNext()) {

      historyText.append('"').append(massageHistoryField(cursor.getString(0))).append("\",");
      historyText.append('"').append(massageHistoryField(cursor.getString(1))).append("\",");
      historyText.append('"').append(massageHistoryField(cursor.getString(2))).append("\",");
      historyText.append('"').append(massageHistoryField(cursor.getString(3))).append("\",");

      // Add timestamp again, formatted
      long timestamp = cursor.getLong(3);
      historyText.append('"').append(massageHistoryField(
          EXPORT_DATE_TIME_FORMAT.format(new Date(timestamp)))).append("\",");

      // Above we're preserving the old ordering of columns which had formatted data in position 5

      historyText.append('"').append(massageHistoryField(cursor.getString(4))).append("\"\r\n");
    }
    return historyText;
  } finally {
    close(cursor, db);
  }
}
 
Example #23
Source File: DesignTestStorIOSQLite.java    From storio with Apache License 2.0 5 votes vote down vote up
@NonNull
@Override
public SQLiteOpenHelper sqliteOpenHelper() {
    // not required in design test
    // noinspection ConstantConditions
    return null;
}
 
Example #24
Source File: HistoryManager.java    From Study_Android_Demo with Apache License 2.0 5 votes vote down vote up
void clearHistory() {
  SQLiteOpenHelper helper = new DBHelper(activity);
  SQLiteDatabase db = null;
  try {
    db = helper.getWritableDatabase();      
    db.delete(DBHelper.TABLE_NAME, null, null);
  } finally {
    close(null, db);
  }
}
 
Example #25
Source File: HistoryManager.java    From zxingfragmentlib with Apache License 2.0 5 votes vote down vote up
void clearHistory() {
  SQLiteOpenHelper helper = new DBHelper(activity);
  SQLiteDatabase db = null;
  try {
    db = helper.getWritableDatabase();      
    db.delete(DBHelper.TABLE_NAME, null, null);
  } finally {
    close(null, db);
  }
}
 
Example #26
Source File: HistoryManager.java    From Study_Android_Demo with Apache License 2.0 5 votes vote down vote up
/**
 * <p>Builds a text representation of the scanning history. Each scan is encoded on one
 * line, terminated by a line break (\r\n). The values in each line are comma-separated,
 * and double-quoted. Double-quotes within values are escaped with a sequence of two
 * double-quotes. The fields output are:</p>
 *
 * <ol>
 *  <li>Raw text</li>
 *  <li>Display text</li>
 *  <li>Format (e.g. QR_CODE)</li>
 *  <li>Unix timestamp (milliseconds since the epoch)</li>
 *  <li>Formatted version of timestamp</li>
 *  <li>Supplemental info (e.g. price info for a product barcode)</li>
 * </ol>
 */
CharSequence buildHistory() {
  SQLiteOpenHelper helper = new DBHelper(activity);
  SQLiteDatabase db = null;
  Cursor cursor = null;
  try {
    db = helper.getWritableDatabase();
    cursor = db.query(DBHelper.TABLE_NAME,
                      COLUMNS,
                      null, null, null, null,
                      DBHelper.TIMESTAMP_COL + " DESC");

    DateFormat format = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM);
    StringBuilder historyText = new StringBuilder(1000);
    while (cursor.moveToNext()) {

      historyText.append('"').append(massageHistoryField(cursor.getString(0))).append("\",");
      historyText.append('"').append(massageHistoryField(cursor.getString(1))).append("\",");
      historyText.append('"').append(massageHistoryField(cursor.getString(2))).append("\",");
      historyText.append('"').append(massageHistoryField(cursor.getString(3))).append("\",");

      // Add timestamp again, formatted
      long timestamp = cursor.getLong(3);
      historyText.append('"').append(massageHistoryField(
          format.format(new Date(timestamp)))).append("\",");

      // Above we're preserving the old ordering of columns which had formatted data in position 5

      historyText.append('"').append(massageHistoryField(cursor.getString(4))).append("\"\r\n");
    }
    return historyText;
  } finally {
    close(cursor, db);
  }
}
 
Example #27
Source File: HistoryManager.java    From incubator-weex-playground with Apache License 2.0 5 votes vote down vote up
public boolean hasHistoryItems() {
  SQLiteOpenHelper helper = new DBHelper(activity);
  SQLiteDatabase db = null;
  Cursor cursor = null;
  try {
    db = helper.getReadableDatabase();
    cursor = db.query(DBHelper.TABLE_NAME, COUNT_COLUMN, null, null, null, null, null);
    cursor.moveToFirst();
    return cursor.getInt(0) > 0;
  } finally {
    close(cursor, db);
  }
}
 
Example #28
Source File: DefaultStorIOSQLiteTest.java    From storio with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void instantiatePutContentValues() {
    DefaultStorIOSQLite.builder()
            .sqliteOpenHelper(mock(SQLiteOpenHelper.class))
            .build()
            .put()
            .contentValues(mock(ContentValues.class))
            .withPutResolver(mock(PutResolver.class))
            .prepare();
}
 
Example #29
Source File: SQLiteCursorLoader.java    From itracing2 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a fully-specified SQLiteCursorLoader. See
 * {@link SQLiteDatabase#rawQuery(String, String[], CancellationSignal)}
 * SQLiteDatabase.rawQuery()} for documentation on the
 * meaning of the parameters. These will be passed as-is
 * to that call.
 */
public SQLiteCursorLoader(Context context, SQLiteOpenHelper db,
                          String rawQuery, String[] args)
{
    super(context);
    this.db = db;
    this.rawQuery = rawQuery;
    this.args = args;
}
 
Example #30
Source File: HistoryManager.java    From weex with Apache License 2.0 5 votes vote down vote up
void clearHistory() {
  SQLiteOpenHelper helper = new DBHelper(activity);
  SQLiteDatabase db = null;
  try {
    db = helper.getWritableDatabase();      
    db.delete(DBHelper.TABLE_NAME, null, null);
  } finally {
    close(null, db);
  }
}