I'm new in SQL Android, and i have a question: I saw a lot of tutorials on how to create databases but they all create a SQLiteOpenHelper for each database's class. Honestly i don't think it is a good idea, because for a DB with lot of tables it will mean a lot of thrash-code.
How can I use a generic type for N classes? I need the CREATE TABLE / DROP TABLE / UPDATE TABLE / etc methods which works for a T class, not for (example) a "USER" class.
Can anyone tell me how to do it? i post a piece of code, but i don't know how to generify it.
USER class:
public class USER{
private Integer ID;
private String NAME;
private String SURNAME;
public USER(){}
public USER(String NAME, String SURNAME){
this.NAME = NAME;
this.SURNAME = SURNAME;
}
//getters and setters
}
DOG class:
public class DOG{
private Integer ID;
private String NAME;
private Integer LEGS_NO;
public DOG(){}
public DOG(String NAME, Integer LEGS_NO){
this.NAME = NAME;
this.LEGS_NO= LEGS_NO;
}
//getters and setters
}
How will a generic SQLiteOpenHelper looks like for working for each of those classes? Thanks in advice
Aucun commentaire:
Enregistrer un commentaire