Exemplo n.º 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;
  }
Exemplo n.º 2
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;
  }