Java Code Examples for android.database.sqlite.SQLiteOpenHelper

The following examples show how to use android.database.sqlite.SQLiteOpenHelper. These examples are extracted from open source projects. 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 Project: reacteu-app   Source File: HistoryManager.java    License: 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 Project: reacteu-app   Source File: HistoryManager.java    License: 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 3
Source Project: incubator-weex-playground   Source File: HistoryManager.java    License: 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 Project: incubator-weex-playground   Source File: HistoryManager.java    License: 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 Project: weex   Source File: HistoryManager.java    License: 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
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 Project: barcodescanner-lib-aar   Source File: HistoryManager.java    License: 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
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 9
Source Project: incubator-weex-playground   Source File: HistoryManager.java    License: 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 10
Source Project: itracing2   Source File: SQLiteCursorLoader.java    License: 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];
    String nullColumnHack = (String) params[2];
    ContentValues values = (ContentValues) params[3];

    db.getWritableDatabase().replace(table, nullColumnHack, values);

    return (null);
}
 
Example 11
Source Project: storio   Source File: DefaultStorIOSQLiteTest.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void instantiatePutContentValuesVarArgs() {
    DefaultStorIOSQLite.builder()
            .sqliteOpenHelper(mock(SQLiteOpenHelper.class))
            .build()
            .put()
            .contentValues(mock(ContentValues.class), mock(ContentValues.class))
            .withPutResolver(mock(PutResolver.class))
            .prepare();
}
 
Example 12
Source Project: incubator-weex-playground   Source File: HistoryManager.java    License: 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 13
Source Project: itracing2   Source File: SQLiteCursorLoader.java    License: 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];
    String where = (String) params[2];
    String[] whereParams = (String[]) params[3];

    db.getWritableDatabase().delete(table, where, whereParams);

    return (null);
}
 
Example 14
Source Project: storio   Source File: DefaultStorIOSQLite.java    License: Apache License 2.0 5 votes vote down vote up
protected DefaultStorIOSQLite(
        @NonNull SQLiteOpenHelper sqLiteOpenHelper,
        @NonNull TypeMappingFinder typeMappingFinder,
        @Nullable Scheduler defaultRxScheduler,
        @NonNull List<Interceptor> interceptors) {
    this.sqLiteOpenHelper = sqLiteOpenHelper;
    this.defaultRxScheduler = defaultRxScheduler;
    this.interceptors = unmodifiableNonNullList(interceptors);
    lowLevel = new LowLevelImpl(typeMappingFinder);
}
 
Example 15
Source Project: reacteu-app   Source File: HistoryManager.java    License: MIT License 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()) {
    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 16
Source Project: MiBandDecompiled   Source File: i.java    License: Apache License 2.0 5 votes vote down vote up
public Cursor a(String s)
{
    SQLiteOpenHelper sqliteopenhelper = g;
    Cursor cursor = null;
    if (sqliteopenhelper == null)
    {
        break MISSING_BLOCK_LABEL_68;
    }
    String s1 = "select * from analytics ";
    if (s != null)
    {
        s1 = String.format("%s where %s", new Object[] {
            "select * from analytics ", s
        });
    }
    SQLiteDatabase sqlitedatabase;
    Cursor cursor1;
    try
    {
        sqlitedatabase = g.getReadableDatabase();
    }
    catch (SQLiteException sqliteexception)
    {
        Object aobj[] = new Object[1];
        aobj[0] = g.getDatabaseName();
        Log.e("ANALYTICS.SQLITESTORE", String.format("can't read database:%s", aobj));
        return null;
    }
    cursor = null;
    if (sqlitedatabase == null)
    {
        break MISSING_BLOCK_LABEL_68;
    }
    cursor1 = sqlitedatabase.rawQuery(s1, null);
    cursor = cursor1;
    return cursor;
}
 
Example 17
Source Project: android-skeleton-project   Source File: DataSQLiteDB.java    License: MIT License 5 votes vote down vote up
@Override
public SQLiteOpenHelper getHelper() {
    if (helper == null) {
        helper = new DatabaseHelper(context, dbName, dbVersion, this);
        helper.getWritableDatabase(); //results in db onCreate being called
    }
    return helper;
}
 
Example 18
Source Project: itracing2   Source File: SQLiteCursorLoader.java    License: 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 19
Source Project: storio   Source File: DefaultStorIOSQLiteTest.java    License: 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 20
Source Project: Study_Android_Demo   Source File: HistoryManager.java    License: 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 21
Source Project: zxingfragmentlib   Source File: HistoryManager.java    License: 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 22
Source Project: Study_Android_Demo   Source File: HistoryManager.java    License: 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 23
Source Project: storio   Source File: DesignTestStorIOSQLite.java    License: 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 Project: ZXing-Standalone-library   Source File: HistoryManager.java    License: 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 25
Source Project: android-apps   Source File: HistoryManager.java    License: 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 26
Source Project: weex   Source File: HistoryManager.java    License: 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 27
Source Project: ZXing-Standalone-library   Source File: HistoryManager.java    License: 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 28
Source Project: AnDevCon-RxPatterns   Source File: Example2.java    License: 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 29
Source Project: itracing2   Source File: SQLiteCursorLoader.java    License: 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 30
Source Project: reacteu-app   Source File: HistoryManager.java    License: 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);
  }
}