Android ORMLite, use pre-populated database and use it
I have a pre-populated database, I hadd .csv and make a database in sqllite manager and imported all values into this database.
Now I put this database into android's assets folder and want to use this via ORMLite in my android application.
Please, need your help and w开发者_如何学Cill be thankful to you.
Now I put this database into android's assets folder and want to use this via ORMLite in my android application.
Boy there is a lot of ground to cover here to use ORMLite with this.
The short answer is that you will need to create Java objects which correspond to your database tables. Each Java object should have fields that match the table columns with the appropriate types with @DatabaseField
annotations.
For example, if you CSV file was:
# name, id, street
Bill Jones,123,131 Main St.
and your table created is something like:
create table user (name VARCHAR(255), integer id, street VARCHAR(255));
The Java object you will need is something like:
public class User {
@DatabaseField(id = true)
int id;
@DatabaseField
String name;
@DatabaseField
String street;
}
Then you would use ORMLite to read in objects from your database. You should see the ORMLite home page and the Getting Started section of the documentation. For linking up with the existing database, you should read the section of the manual about using with Android.
Any additional questions I'd ask to the ORMLite Users Mailing List.
精彩评论