开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜