Sqlite Query中的异常

时间:2012-09-21 11:34:45

标签: android sqlite

我在我的方法中使用以下查询

 Cursor c = sqLiteDatabase.rawQuery("SELECT Content3 FROM " +
             MYDATABASE_TABLE +
             " where Content1 = '"+value1+"'", null);

但它会抛出异常,应用程序会被强制关闭。我将value1传递给方法。 Logcat如下

09-21 17:14:21.242: ERROR/AndroidRuntime(16511): FATAL EXCEPTION: main
09-21 17:14:21.242: ERROR/AndroidRuntime(16511): android.database.sqlite.SQLiteException: no such column: Content3: , while compiling: SELECT Content3 FROM photodetails where Content1 = '2192012'
09-21 17:14:21.242: ERROR/AndroidRuntime(16511):     at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)
09-21 17:14:21.242: ERROR/AndroidRuntime(16511):     at android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:92)
09-21 17:14:21.242: ERROR/AndroidRuntime(16511):     at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:65)
09-21 17:14:21.242: ERROR/AndroidRuntime(16511):     at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:83)
09-21 17:14:21.242: ERROR/AndroidRuntime(16511):     at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:49)
09-21 17:14:21.242: ERROR/AndroidRuntime(16511):     at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:42)
09-21 17:14:21.242: ERROR/AndroidRuntime(16511):     at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1356)
09-21 17:14:21.242: ERROR/AndroidRuntime(16511):     at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1324)
09-21 17:14:21.242: ERROR/AndroidRuntime(16511):     at roman10.tutorial.fileobserver.SQLiteAdapter.fetchresult(SQLiteAdapter.java:80)
09-21 17:14:21.242: ERROR/AndroidRuntime(16511):     at roman10.tutorial.fileobserver.FileModificationMonitor$3.onClick(FileModificationMonitor.java:56)
09-21 17:14:21.242: ERROR/AndroidRuntime(16511):     at android.view.View.performClick(View.java:2485)
09-21 17:14:21.242: ERROR/AndroidRuntime(16511):     at android.view.View$PerformClick.run(View.java:9080)
09-21 17:14:21.242: ERROR/AndroidRuntime(16511):     at android.os.Handler.handleCallback(Handler.java:587)
09-21 17:14:21.242: ERROR/AndroidRuntime(16511):     at android.os.Handler.dispatchMessage(Handler.java:92)
09-21 17:14:21.242: ERROR/AndroidRuntime(16511):     at android.os.Looper.loop(Looper.java:130)
09-21 17:14:21.242: ERROR/AndroidRuntime(16511):     at android.app.ActivityThread.main(ActivityThread.java:3687)
09-21 17:14:21.242: ERROR/AndroidRuntime(16511):     at java.lang.reflect.Method.invokeNative(Native Method)
09-21 17:14:21.242: ERROR/AndroidRuntime(16511):     at java.lang.reflect.Method.invoke(Method.java:507)
09-21 17:14:21.242: ERROR/AndroidRuntime(16511):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
09-21 17:14:21.242: ERROR/AndroidRuntime(16511):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
09-21 17:14:21.242: ERROR/AndroidRuntime(16511):     at dalvik.system.NativeStart.main(Native Method)

请指出我的错误。感谢

1 个答案:

答案 0 :(得分:0)

最后我得到了解决我的问题的方法..只需删除文件资源管理器中的数据库 - &gt; data / data / packagename / dbname。并再次运行。现在它工作正常。