I have the following snippet:
public void readUsersSugarDB() {
// SUGAR DB TEST
try {
List<User> users = User.listAll(User.class);
for (int i = 0; i < users.size(); i++) {
User userObject = users.get(i);
Logger.i(userObject.getUserName());
Logger.i(userObject.toString());
}
//Integer userCount = User.getTableName(User.class);
Logger.i("Users list", users);
} catch (Exception e) {
Logger.e("Sugar_db_exception", e.getMessage());
}
}
I would like to access directly to the object properties (name, surname) but i cannnot. I must to create getter Method on the model to get name and surname.
Is possible to access object attributes without having to create getters on the model? Anf if yes, how can i do it in the right way please?
Many thanks for any advice.
Model class:
public class User extends SugarRecord<User>{
String name;
String surname;
public User() {
}
public User(String name, String surname) {
this.name = name;
this.surname = surname;
}
public String getUserName() {
return this.name;
}
}
Aucun commentaire:
Enregistrer un commentaire