Android SQLite没有这样的表/预填充数据库
基于本文,我在应用程序中预装了一个sqlite数据库: [链接] 因此,将成功创建/复制/打开数据库(DDMS、文件浏览器等)。在下一步中,我想在表中插入一些数据。然后我得到了“没有这样的表格”的错误,我不明白为什么 创建/打开数据库Android SQLite没有这样的表/预填充数据库,android,sqlite,Android,Sqlite,基于本文,我在应用程序中预装了一个sqlite数据库: [链接] 因此,将成功创建/复制/打开数据库(DDMS、文件浏览器等)。在下一步中,我想在表中插入一些数据。然后我得到了“没有这样的表格”的错误,我不明白为什么 创建/打开数据库 public void createSQLite() { try { helper.createDataBase(); helper.openDataBase(); } catch (IOException e) {
public void createSQLite() {
try {
helper.createDataBase();
helper.openDataBase();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static final String cust_id = "customer_id_fk";
public static final String app_cust_id = "app_cust_id_pk";
public static final String hash = "app_hashvalue";
public static final String version = "app_version";
public static final String date = "activation_date";
public static final String handy = "handynr";
public static final String device = "devicename";
public static final String active = "activated";
public static final String APP_CUSTOMER = "app_customer";
表格的名称和属性
public void createSQLite() {
try {
helper.createDataBase();
helper.openDataBase();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static final String cust_id = "customer_id_fk";
public static final String app_cust_id = "app_cust_id_pk";
public static final String hash = "app_hashvalue";
public static final String version = "app_version";
public static final String date = "activation_date";
public static final String handy = "handynr";
public static final String device = "devicename";
public static final String active = "activated";
public static final String APP_CUSTOMER = "app_customer";
插入选项卡中
public void addAppCustomer(Activation act) {
long rowId = -1;
SQLiteDatabase db = sqlite.getWritableDatabase();
ContentValues val = new ContentValues();
// Create values
val.put(app_cust_id, act.getApp_customer_id());
val.put(cust_id, act.getCustomer_id());
val.put(hash, act.getImei());
val.put(version, act.getAppversion());
val.put(date, act.getActivationDate());
val.put(handy, act.getPhone_number());
val.put(device, act.getDevice_name());
val.put(active, act.getActivated());
rowId = db.insert(APP_CUSTOMER, null, val);
}
再次:创建数据库/表。当尝试插入上述数据时,我得到“无此类表格”错误(app\U客户)
提前谢谢
编辑:
创建表语句
CREATE TABLE `app_customer` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`app_cust_id_pk` INTEGER NOT NULL,
`customer_id_fk` INTEGER NOT NULL,
`app_hashvalue` VARCHAR(128) NOT NULL,
`app_version` VARCHAR(45) NOT NULL,
`activation_date` NUMERIC NOT NULL,
`handynr` VARCHAR(16) NOT NULL,
`devicename` VARCHAR(45) NOT NULL,
`activated` INTEGER NOT NULL DEFAULT '0'
)
你能发布创建表语句吗?请考虑使用比五岁的博客文章更现代的东西,这样。我已经更新了我的问题(见创建表)。