我对ORMLIte website上列出的示例有两个问题。
答案 0 :(得分:0)
我在哪里放数据库以及如何导入数据库。
你的意思是h2 jar文件?如入门文档(1.4代码示例)中所述,您需要将h2 jar文件添加到类路径中。如果您不确定如何设置类路径,请首先进行调查,因为这是Java中非常重要的概念。
答案 1 :(得分:0)
您必须使用注释创建数据库模型 @DatabaseTable()
和
@DatabaseField()
像:
@DatabaseTable(tableName="YOUR_TABLE_NAME")
public class SimpleDataModel {
@DatabaseField(id=true)
private int idSimpleData;
@DatabaseField()
private String NameSomeDataHere;
}
您不必导入它,只需创建一个扩展为ORMSqliteOpenHelper的Helper类。
有很好的记录,只需在ORMLite网站上搜索一下。但一个例子是:
public class dbHelper extends ORMSqliteOpenHelper {
onCreate() { // I'm letting some code behind, as long as Eclipse do implement methods for you. ;)
TableUtils.CreateTable(connectionSource, SimpleDataModel.class);
//This one above is what is going to create your tables.
//Afterwards you have to use DAO's to access your data, os it's nonsense.
//So if you're a begginner at android just read the ENTIRE documentarion of ORMLite, and MAYBE you'll understand something ;P
}