Пример #1
0
  public void addCount(ArrayList<InUseFriendCountEntity> countList) {
    SQLiteDatabase db = this.getWritableDatabase();
    db.delete(TABLE_INUSEFRIENDCOUNT, null, null);
    for (InUseFriendCountEntity contact : countList) {
      ContentValues values = new ContentValues();
      values.put(KEY_USERSN, contact.getUserSN());
      values.put(KEY_COUNT, contact.getCount());

      db.insert(TABLE_INUSEFRIENDCOUNT, null, values);
    }
    _inUseFriendCount = null;
  }
Пример #2
0
  public HashMap<String, String> getAllCount() {
    if (_inUseFriendCount != null) return _inUseFriendCount;

    HashMap<String, String> inUseFriendCount = new HashMap<String, String>();
    String selectQuery = "SELECT * FROM " + TABLE_INUSEFRIENDCOUNT;

    SQLiteDatabase db = this.getWritableDatabase();
    Cursor cursor = db.rawQuery(selectQuery, null);
    if (cursor.moveToFirst()) {
      do {
        InUseFriendCountEntity entity =
            new InUseFriendCountEntity(
                cursor.getString(cursor.getColumnIndex(KEY_USERSN)),
                cursor.getString(cursor.getColumnIndex(KEY_COUNT)));

        if (inUseFriendCount.containsKey(entity.getUserSN()) == false)
          inUseFriendCount.put(entity.getUserSN(), entity.getCount());

      } while (cursor.moveToNext());
    }
    cursor.close();
    _inUseFriendCount = inUseFriendCount;
    return _inUseFriendCount;
  }