尝试更新SQLite数据库时出现Android Studio错误

时间:2017-04-04 19:52:51

标签: android sqlite

我一直在线阅读教程,在我的Android Studio应用程序项目中实现数据库。但是我使用相同的代码,但每次运行模拟器时都会遇到相同的错误并尝试更新我的记录之一: UNFORTUNETLY项目已停止运行

我检查了我的logcat,出现以下内容:

  

崩溃开始04-04 20:25:23.290   4019-4019 / com.example.mark.messaround2 E / AndroidRuntime:致命   例外:主要                                                                               处理:com.example.mark.messaround2,PID:4019                                                                               android.database.sqlite.SQLiteException:没有这样的列:ID(代码1):   ,编译时:UPDATE DAY_TABLE SET NAME = ?, ID = ?, MARKS = ?, SURNAME =?   在哪里ID =?                                                                                   在   android.database.sqlite.SQLiteConnection.nativePrepareStatement(母语   方法)                                                                                   在   android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:889)                                                                                   在   android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:500)                                                                                   在   android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)                                                                                   在android.database.sqlite.SQLiteProgram。(SQLiteProgram.java:58)                                                                                   在   android.database.sqlite.SQLiteStatement。(SQLiteStatement.java:31)                                                                                   在   android.database.sqlite.SQLiteDatabase.updateWithOnConflict(SQLiteDatabase.java:1577)                                                                                   在   android.database.sqlite.SQLiteDatabase.update(SQLiteDatabase.java:1525)                                                                                   在   com.example.mark.AutismApplicationSuite.DatabaseHelper.updateData(DatabaseHelper.java:75)                                                                                   在   com.example.mark.AutismApplicationSuite.ChooseDayScreen $ 9.onClick(ChooseDayScreen.java:152)                                                                                   在android.view.View.performClick(View.java:5610)                                                                                   在android.view.View $ PerformClick.run(View.java:22265)                                                                                   在android.os.Handler.handleCallback(Handler.java:751)                                                                                   在android.os.Handler.dispatchMessage(Handler.java:95)                                                                                   在android.os.Looper.loop(Looper.java:154)                                                                                   在android.app.ActivityThread.main(ActivityThread.java:6077)                                                                                   at java.lang.reflect.Method.invoke(Native Method)                                                                                   在   com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:865)                                                                                   在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)

1 个答案:

答案 0 :(得分:0)

检查这两个,其中任何一个都适合你。

  1. 在" DAY_TABLE"中,您没有为" ID"制作任何属性。所以创建一个名为的属性 " ID"并更新DB的版本
  2. 更改" DAY_TABLE"后,您没有更新数据库版本。