示例#1
0
  public User getUserDetails(String profile, Context ctx) {

    dbUtil = new DatabaseUtil(ctx);
    dbUtil.open();

    User tempUser = new User();
    // String name="sun";

    Cursor cursor = dbUtil.fetchProfile(profile);

    tempUser.setUser("na");

    if (cursor != null) {
      while (cursor.moveToNext()) {
        tempUser.setUser(profile);
        tempUser.setGender(cursor.getString(1));
        tempUser.setDob(cursor.getString(2));
        tempUser.setWeight(cursor.getFloat(3));
        tempUser.setHeight(cursor.getFloat(4));
        // tempUser.setDesc(cursor.getString(5));
        tempUser.setType(cursor.getString(6));
      }
    } else Toast.makeText(ctx, "Cannot load profile", Toast.LENGTH_LONG);

    dbUtil.close();
    if (tempUser.getUser().equalsIgnoreCase("na")) {
      tempUser.setUser(profile);
      init(ctx, tempUser);
    }

    return tempUser;
  }