表格未创建

no such table: acce
2019-11-09 23:31:06.088 14319-14319/com.example.a3_phd19006 E/SQLiteDatabase: Error inserting x=3.9840088 y=6.031311 z=6.60054
    android.database.sqlite.SQLiteException: no such table: acce (code 1):,while compiling: INSERT INTO acce(x,y,z) VALUES (?,?,?)

这是我的DBHelper

public DBHelper(Context context) {

    super(context,DATABASE_NAME,null,1);
    Log.d("sdfjh","databasecreated");
}

public void onCreate(SQLiteDatabase db) {
    // TODO Auto-generated method stub
    db.execSQL(
            "CREATE TABLE "+ accE_TABLE_NAME +
                    " (" + X + " text," + Y + " text," + Z + " text)"
    );
}

public boolean insertacce (String x,String y,String z) {
    SQLiteDatabase db = this.getwritabledatabase();
    Contentvalues contentvalues = new Contentvalues();
    contentvalues.put(X,x);
    contentvalues.put(Y,y);
    contentvalues.put(Z,z);
   long flag= db.insert(accE_TABLE_NAME,contentvalues);
    if(flag==-1){
        return false;
    }
    else {
        Log.d("shk","inserted");
        return true;
    }
}

在这里我要插入(在服务类中):

DBHelper dh = new DBHelper(this.getapplication());

public void onSensorChanged(SensorEvent event) {
    float x = event.values[0];
    float y = event.values[1];
    float z = event.values[2];
    if (!mInitialized) mInitialized = true;
    Log.d("cooridate",x+" "+y+" "+z);

    dh.insertacce(Float.toString(x),Float.toString(y),Float.toString(z));

    long tsLong = System.currentTimeMillis()/2000;
    if (tsLong > lastTime+period) {
        lastTime = tsLong;

    }
}
hjghjgdf54 回答:表格未创建

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3131810.html

大家都在问