Beispiel #1
0
 // returns all groups saved on the local DB
 public static ArrayList<Group> all() {
   SQLiteDatabase db = DBHandle.getConnection();
   Cursor cur = db.query(tableName, null, null, null, null, null, null);
   ArrayList<Group> list = fromCursor(cur);
   cur.close();
   return list;
 }
Beispiel #2
0
 public static ArrayList<Group> findByName(String name) {
   SQLiteDatabase db = DBHandle.getConnection();
   String query = "SELECT * FROM " + tableName + " WHERE name = ?";
   Cursor cur = db.rawQuery(query, new String[] {name});
   ArrayList<Group> found = fromCursor(cur);
   cur.close();
   return found;
 }
Beispiel #3
0
 // find an object in the local DB by ID
 public static Group find(String id) {
   SQLiteDatabase db = DBHandle.getConnection();
   String query = "SELECT * FROM " + tableName + " WHERE _id = ?";
   Cursor cur = db.rawQuery(query, new String[] {id});
   Group found = fromCursor(cur).get(0);
   cur.close();
   return found;
 }
Beispiel #4
0
 // checks the local DB to see if an object with this ID exists
 public static boolean exists(String id) {
   SQLiteDatabase db = DBHandle.getConnection();
   String query = "SELECT * FROM " + tableName + " WHERE _id = ?";
   Cursor cur = db.rawQuery(query, new String[] {id});
   boolean exists = (cur.getCount() == 1);
   cur.close();
   return exists;
 }