示例#1
0
  // Member Start
  public Profile getMember(String id) {
    Profile profile = new Profile();
    try {
      SQLiteDatabase db = this.getWritableDatabase();

      Cursor cursor =
          db.query(
              DBProfile.TABLE_NAME,
              null,
              DBProfile.ID + "=?",
              new String[] {id},
              null,
              null,
              null,
              "1");
      cursor.moveToFirst();

      if (cursor.getCount() == 1) {
        profile.ID = cursor.getString(cursor.getColumnIndex(DBProfile.ID));
        profile.NAME = cursor.getString(cursor.getColumnIndex(DBProfile.NAME));
        profile.RELATIONSHIP = cursor.getString(cursor.getColumnIndex(DBProfile.RELATIONSHIP));
        profile.HEIGHT = cursor.getString(cursor.getColumnIndex(DBProfile.HEIGHT));
        profile.WEIGHT = cursor.getString(cursor.getColumnIndex(DBProfile.WEIGHT));
        profile.GENDER = cursor.getString(cursor.getColumnIndex(DBProfile.GENDER));
        profile.AGE = cursor.getString(cursor.getColumnIndex(DBProfile.AGE));
        profile.PHOTO = cursor.getString(cursor.getColumnIndex(DBProfile.PHOTO));
        profile.PHONE = cursor.getString(cursor.getColumnIndex(DBProfile.PHONE));
      }
    } catch (Exception e) {
      L.log(e.toString());
    }
    return profile;
  }
示例#2
0
  public ArrayList<Profile> getmembers() {
    ArrayList<Profile> arrayList = new ArrayList<>();
    try {
      SQLiteDatabase db = this.getReadableDatabase();

      Cursor cursor =
          db.query(
              DBProfile.TABLE_NAME,
              null,
              DBProfile.RELATIONSHIP + "!=?",
              new String[] {"none"},
              null,
              null,
              null,
              null);
      cursor.moveToFirst();

      while (!cursor.isAfterLast()) {
        Profile profile = new Profile();
        profile.ID = cursor.getString(cursor.getColumnIndex(DBProfile.ID));
        profile.NAME = cursor.getString(cursor.getColumnIndex(DBProfile.NAME));
        profile.AGE = cursor.getString(cursor.getColumnIndex(DBProfile.AGE));
        profile.HEIGHT = cursor.getString(cursor.getColumnIndex(DBProfile.HEIGHT));
        profile.WEIGHT = cursor.getString(cursor.getColumnIndex(DBProfile.WEIGHT));
        profile.PHOTO = cursor.getString(cursor.getColumnIndex(DBProfile.PHOTO));
        profile.RELATIONSHIP = cursor.getString(cursor.getColumnIndex(DBProfile.RELATIONSHIP));

        arrayList.add(profile);
        cursor.moveToNext();
      }
      cursor.close();
      db.close();
    } catch (Exception e) {
      L.log(e.toString());
    }
    return arrayList;
  }
示例#3
0
  public Profile getMyProfileMain() {
    SQLiteDatabase db = this.getReadableDatabase();
    Profile myProfile = null;
    try {
      Cursor cursor =
          db.query(
              DBProfile.TABLE_NAME,
              null,
              DBProfile.RELATIONSHIP + "=?",
              new String[] {"none"},
              null,
              null,
              null,
              "1");
      cursor.moveToFirst();

      while (!cursor.isAfterLast()) {
        myProfile = new Profile();
        myProfile.ID = cursor.getString(cursor.getColumnIndex(DBProfile.ID));
        myProfile.NAME = cursor.getString(cursor.getColumnIndex(DBProfile.NAME));
        myProfile.AGE = cursor.getString(cursor.getColumnIndex(DBProfile.AGE));
        myProfile.GENDER = cursor.getString(cursor.getColumnIndex(DBProfile.GENDER));
        myProfile.HEIGHT = cursor.getString(cursor.getColumnIndex(DBProfile.HEIGHT));
        myProfile.WEIGHT = cursor.getString(cursor.getColumnIndex(DBProfile.WEIGHT));
        myProfile.PHONE = cursor.getString(cursor.getColumnIndex(DBProfile.PHONE));
        myProfile.RELATIONSHIP = cursor.getString(cursor.getColumnIndex(DBProfile.RELATIONSHIP));
        cursor.moveToNext();
      }
      cursor.close();
      db.close();

    } catch (Exception e) {
      L.log(e.getMessage());
    }
    return myProfile;
  }