示例#1
0
  private void write(String service, String action) {
    // Gets the data repository in write mode
    SQLiteDatabase db = mDbHelper.getWritableDatabase();

    // Create a new map of values, where column names are the keys
    ContentValues values = new ContentValues();

    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
    Date date = new Date();

    values.put(AlertLogContract.AlertLogEntry.COLUMN_NAME_SERVICE, service);
    values.put(AlertLogContract.AlertLogEntry.COLUMN_NAME_ACTION, action);
    values.put(AlertLogContract.AlertLogEntry.COLUMN_NAME_ADDED, dateFormat.format(date));

    db.insert(
        AlertLogContract.AlertLogEntry.TABLE_NAME,
        AlertLogContract.AlertLogEntry.NULL_COLUMN_HACK,
        values);
  }
示例#2
0
 private void purge() {
   // Gets the data repository in write mode
   SQLiteDatabase db = mDbHelper.getWritableDatabase();
   mDbHelper.onUpgrade(db, 1, 1);
 }