Exemple #1
0
 public static User read(String userName) {
   Cursor c = dbhelp.read(userName);
   if (c.moveToFirst()) {
     User user =
         new User(
             c.getString(c.getColumnIndex("user_name")),
             c.getString(c.getColumnIndex("hometown")),
             c.getString(c.getColumnIndex("birthplace")));
     user.password = c.getString(c.getColumnIndex("password"));
     return user;
   }
   return null;
 }
Exemple #2
0
 public static ArrayList<User> readAll() {
   ArrayList<User> retVal = new ArrayList<>();
   Cursor c = dbhelp.readAll();
   if (c.moveToFirst()) {
     do {
       User user =
           new User(
               c.getString(c.getColumnIndex("user_name")),
               c.getString(c.getColumnIndex("hometown")),
               c.getString(c.getColumnIndex("birthplace")));
       user.password = c.getString(c.getColumnIndex("password"));
       retVal.add(user);
     } while (c.moveToNext());
   }
   return retVal;
 }