Esempio n. 1
0
  // retrieves a group, by ID, from the server
  public static boolean fromServer(String id) {
    HttpResponse resp = Connection.getRequest("/" + tableName + "/" + id);
    if (resp == null || resp.getStatusLine().getStatusCode() != 200) return false;
    Group g = new Group();
    g._id = Integer.parseInt(resp.getHeaders("Id")[0].getValue());
    g.name = resp.getHeaders("Name")[0].getValue();
    g.desc = resp.getHeaders("Desc")[0].getValue();
    g.website = resp.getHeaders("Website")[0].getValue();
    g.globalSaved = true;

    return g.saveLocally();
  }
Esempio n. 2
0
 // given a cursor, returns a list of Groups it contains
 public static ArrayList<Group> fromCursor(Cursor cur) {
   ArrayList<Group> list = new ArrayList<Group>();
   if (cur.moveToFirst()) {
     do {
       // Get the field values
       Group g = new Group();
       g._id = Integer.valueOf(cur.getString(cur.getColumnIndex("_id")));
       g.name = cur.getString(cur.getColumnIndex("name"));
       g.desc = cur.getString(cur.getColumnIndex("desc"));
       g.website = cur.getString(cur.getColumnIndex("website"));
       g.globalSaved = true;
       list.add(g);
     } while (cur.moveToNext());
   }
   return list;
 }