Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/220.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java DB:“表”没有名为“名称列”的列_Java_Android_Sqlite - Fatal编程技术网

Java DB:“表”没有名为“名称列”的列

Java DB:“表”没有名为“名称列”的列,java,android,sqlite,Java,Android,Sqlite,我在启动应用程序时遇到此问题,它导致我出现以下错误: E/SQLiteLog: (1) table geophysics_table has no column named municipality E/SQLiteDatabase: Error inserting id_grid=1 culture_type= resolution_survey= soil_type= coordinates= finish_date= start_date= municipality= site= soft

我在启动应用程序时遇到此问题,它导致我出现以下错误:

E/SQLiteLog: (1) table geophysics_table has no column named municipality
E/SQLiteDatabase: Error inserting id_grid=1 culture_type= resolution_survey= soil_type= coordinates= finish_date= start_date= municipality= site= software= range= ctr= assistans= frequency_feeler= igm= max_depth= instrument_type= area_investigated= description_site= n_tab= author= acquisition_method= survey_method= ref_geo_map=
                  android.database.sqlite.SQLiteException: table geophysics_table has no column named municipality (code 1): , while compiling: INSERT INTO geophysics_table(id_grid,culture_type,resolution_survey,soil_type,coordinates,finish_date,start_date,municipality,site,software,range,ctr,assistans,frequency_feeler,igm,max_depth,instrument_type,area_investigated,description_site,n_tab,author,acquisition_method,survey_method,ref_geo_map) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
                      at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
                      at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:889)
                      at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:500)
                      at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
                      at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
                      at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
                      at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1469)
                      at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1341)
                      at com.example.giuse.secondly.DBTools.insertGrid(DBTools.java:85)
                      at com.example.giuse.secondly.NewSheet.saveData(NewSheet.java:104)
                      at java.lang.reflect.Method.invoke(Native Method)
                      at java.lang.reflect.Method.invoke(Method.java:372)
                      at android.view.View$1.onClick(View.java:4015)
                      at android.view.View.performClick(View.java:4780)
                      at android.view.View$PerformClick.run(View.java:19866)
                      at android.os.Handler.handleCallback(Handler.java:739)
                      at android.os.Handler.dispatchMessage(Handler.java:95)
                      at android.os.Looper.loop(Looper.java:135)
                      at android.app.ActivityThread.main(ActivityThread.java:5254)
                      at java.lang.reflect.Method.invoke(Native Method)
                      at java.lang.reflect.Method.invoke(Method.java:372)
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
W/EGL_emulation: eglSurfaceAttrib not implemented
W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0x7fa4f2464180, error=EGL_SUCCESS

可能您必须提高数据库版本

递增后,将调用onUpgrade方法

因此,您可以将所有表放到这里,然后调用onCreate

范例

public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    db.execSQL("DROP TABLE IF EXISTS firstTable");
    db.execSQL("DROP TABLE IF EXISTS secondTable");
    db.execSQL("DROP TABLE IF EXISTS thirdTable");
    onCreate(db);
}

尝试创建一个新的DB表。您最近是否在数据库中没有该列的情况下运行应用程序,并且未能更改数据库版本以通知应用程序重新创建该表?该列肯定是在上一次应用程序运行后添加的。只需从设备卸载应用程序并重新运行即可解决您的问题您是否尝试卸载并安装应用程序再一次
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    db.execSQL("DROP TABLE IF EXISTS firstTable");
    db.execSQL("DROP TABLE IF EXISTS secondTable");
    db.execSQL("DROP TABLE IF EXISTS thirdTable");
    onCreate(db);
}