Пример #1
0
 public void deleteThread(SQLiteDatabase db, String thread) {
   String jid = Message.getUserId(thread);
   execSQL(
       db,
       "delete from " + TABLE_CHAT + " where FROMJID = ? or TOJID = ?;",
       new Object[] {jid, jid});
 }
Пример #2
0
 public void read(SQLiteDatabase db, String fromJid) {
   try {
     db.execSQL(
         "UPDATE " + TABLE_CHAT + " set STATE = ? where FROMJID = ? and STATE = ?",
         new Object[] {Message.READ, Message.getUserId(fromJid), Message.UNREAD});
   } catch (SQLException e) {
     Log.e(TAG, "Error adding new message:" + e.getMessage(), e);
   }
 }
Пример #3
0
 public int getUnreadCount(SQLiteDatabase db, String fromJid) {
   int unread = 0;
   try {
     Cursor cursor =
         db.rawQuery(
             "SELECT count(ID) FROM " + TABLE_CHAT + " where STATE = ? AND FROMJID = ?",
             new String[] {String.valueOf(Message.UNREAD), Message.getUserId(fromJid)});
     int count = cursor.getCount();
     if (count > 0 && cursor.moveToFirst()) {
       unread = cursor.getInt(0);
     }
     cursor.close();
   } catch (SQLException e) {
     Log.e(TAG, "Error adding new message:" + e.getMessage(), e);
   }
   return unread;
 }