Android SQLite没有这样的表/预填充数据库

时间:2014-02-07 12:35:51

标签: android sqlite

我根据这篇文章在我的应用程序中预先填充sqlite数据库: [链接] http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/

因此,将成功创建/复制/打开数据库(DDMS,文件资源管理器,...)。在下一步中,我想将一些数据插入表中。然后我得到“没有这样的表”错误,我不会解释为什么。

创建/打开数据库

public void createSQLite() {
    try {
        helper.createDataBase();
        helper.openDataBase();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

NAME AND ATTRIBUTES OT TABLE

    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";

INSERT INTO TABE

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_customer)。

提前致谢!

修改

创建表语句

    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'
    )

0 个答案:

没有答案