コード例 #1
0
 public ArrayList<User> getAllContacts() {
   SQLiteDatabase db = mDbHelper.getReadableDatabase();
   ArrayList<User> contactList = new ArrayList<User>();
   String selectQuery = "SELECT " + ThreadHelper.DB_NAME + " FROM " + ThreadHelper.DB_TABLE;
   try {
     Cursor cursor = db.rawQuery(selectQuery, null);
     if (cursor.moveToPosition(1)) { // set 1 cause 0 is myself
       do {
         contactList.add(new User(cursor.getString(0)));
       } while (cursor.moveToNext());
     }
   } catch (NullPointerException e) {
     // No entry found
   }
   return contactList;
 }
コード例 #2
0
 public String getContactName(int id) {
   SQLiteDatabase db = mDbHelper.getReadableDatabase();
   Cursor cursor =
       db.query(
           ThreadHelper.DB_TABLE,
           new String[] {ThreadHelper.DB_NAME},
           ThreadHelper.DB_ID + "=?",
           new String[] {String.valueOf(id)},
           null,
           null,
           null,
           null);
   if (cursor != null) cursor.moveToFirst();
   try {
     return cursor.getString(0);
   } catch (CursorIndexOutOfBoundsException e) {
     Log.e(TAG, e.getMessage());
   }
   return null;
 }
コード例 #3
0
 public String getContactPassword() {
   SQLiteDatabase db = mDbHelper.getReadableDatabase();
   Cursor cursor =
       db.query(
           ThreadHelper.DB_TABLE,
           new String[] {ThreadHelper.DB_PASSWORD},
           ThreadHelper.DB_ID + "=?",
           new String[] {"0"},
           null,
           null,
           null,
           null);
   if (cursor != null) cursor.moveToFirst();
   try {
     return cursor.getString(0);
   } catch (CursorIndexOutOfBoundsException e) {
     Log.e(TAG, e.getMessage());
   }
   return null;
 }
コード例 #4
0
 public String getPrivateKey(int id) {
   String result = null;
   SQLiteDatabase db = mDbHelper.getReadableDatabase();
   Cursor cursor =
       db.query(
           ThreadHelper.DB_TABLE,
           new String[] {ThreadHelper.DB_PRIVATE},
           ThreadHelper.DB_ID + "=?",
           new String[] {String.valueOf(id)},
           null,
           null,
           null,
           null);
   try {
     if (cursor != null) cursor.moveToFirst();
     result = cursor.getString(0);
   } catch (CursorIndexOutOfBoundsException e) {
     Log.e(TAG, e.getMessage());
   }
   return result;
 }
コード例 #5
0
 public String getPublicKey(String name) {
   String result = null;
   SQLiteDatabase db = mDbHelper.getReadableDatabase();
   Cursor cursor =
       db.query(
           ThreadHelper.DB_TABLE,
           new String[] {ThreadHelper.DB_PUBLIC},
           ThreadHelper.DB_NAME + "=?",
           new String[] {name},
           null,
           null,
           null,
           null);
   try {
     if (cursor != null) cursor.moveToFirst();
     result = cursor.getString(0);
   } catch (CursorIndexOutOfBoundsException e) {
     Log.e(TAG, e.getMessage());
   }
   return result;
 }
コード例 #6
0
 public boolean isset(String name) {
   SQLiteDatabase db = mDbHelper.getReadableDatabase();
   try {
     Cursor cursor =
         db.query(
             ThreadHelper.DB_TABLE,
             new String[] {ThreadHelper.DB_NAME},
             ThreadHelper.DB_NAME + "=?",
             new String[] {name},
             null,
             null,
             null,
             null);
     if (cursor != null) cursor.moveToFirst();
     cursor.getString(0);
     return true;
   } catch (CursorIndexOutOfBoundsException e) {
     Log.e(TAG, e.getMessage());
   }
   return false;
 }