コード例 #1
0
  public void setNumbers(
      List<ContactTokenDetails> activeTokens, Collection<String> inactiveTokens) {
    long timestamp = System.currentTimeMillis();
    SQLiteDatabase db = databaseHelper.getWritableDatabase();
    db.beginTransaction();

    try {
      for (ContactTokenDetails token : activeTokens) {
        Log.w("Directory", "Adding active token: " + token.getNumber() + ", " + token.getToken());
        ContentValues values = new ContentValues();
        values.put(NUMBER, token.getNumber());
        values.put(REGISTERED, 1);
        values.put(TIMESTAMP, timestamp);
        values.put(RELAY, token.getRelay());
        values.put(VOICE, token.isVoice());
        db.replace(TABLE_NAME, null, values);
      }

      for (String token : inactiveTokens) {
        ContentValues values = new ContentValues();
        values.put(NUMBER, token);
        values.put(REGISTERED, 0);
        values.put(TIMESTAMP, timestamp);
        db.replace(TABLE_NAME, null, values);
      }

      db.setTransactionSuccessful();
    } finally {
      db.endTransaction();
    }
  }
コード例 #2
0
 public void setNumber(ContactTokenDetails token, boolean active) {
   SQLiteDatabase db = databaseHelper.getWritableDatabase();
   ContentValues values = new ContentValues();
   values.put(NUMBER, token.getNumber());
   values.put(RELAY, token.getRelay());
   values.put(REGISTERED, active ? 1 : 0);
   values.put(TIMESTAMP, System.currentTimeMillis());
   db.replace(TABLE_NAME, null, values);
 }