java.lang.RuntimeException:无法启动活动ComponentInfo?

时间:2012-08-08 21:10:56

标签: android database fatal-error

我一直试图让Android应用程序连接到位于localhost上的数据库,但到目前为止我一直没有运气。我的程序曾经能够启动,我可以在文本字段中输入文本,但是一旦我做了一些更改,它就不会立即启动。我查看了LogCat,我不知道问题是什么。我对此有点新意,认为那里的任何人都可以帮助我吗?

这是来自LogCat的错误日志:

08-08 20:31:35.367: E/AndroidRuntime(605): FATAL EXCEPTION: main
08-08 20:31:35.367: E/AndroidRuntime(605): java.lang.RuntimeException: Unable to start activity     ComponentInfo{com.example.databasetester/com.example.databasetester.DashboardActivity}: android.database.sqlite.SQLiteException: no such table: users: , while compiling: SELECT  * FROM users
08-08 20:31:35.367: E/AndroidRuntime(605):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2049)
08-08 20:31:35.367: E/AndroidRuntime(605):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2083)
08-08 20:31:35.367: E/AndroidRuntime(605):  at android.app.ActivityThread.access$600(ActivityThread.java:134)
08-08 20:31:35.367: E/AndroidRuntime(605):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1233)
08-08 20:31:35.367: E/AndroidRuntime(605):  at android.os.Handler.dispatchMessage(Handler.java:99)
08-08 20:31:35.367: E/AndroidRuntime(605):  at android.os.Looper.loop(Looper.java:137)
08-08 20:31:35.367: E/AndroidRuntime(605):  at android.app.ActivityThread.main(ActivityThread.java:4697)
08-08 20:31:35.367: E/AndroidRuntime(605):  at java.lang.reflect.Method.invokeNative(Native Method)
08-08 20:31:35.367: E/AndroidRuntime(605):  at java.lang.reflect.Method.invoke(Method.java:511)
08-08 20:31:35.367: E/AndroidRuntime(605):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787)
08-08 20:31:35.367: E/AndroidRuntime(605):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554)
08-08 20:31:35.367: E/AndroidRuntime(605):  at dalvik.system.NativeStart.main(Native Method)
08-08 20:31:35.367: E/AndroidRuntime(605): Caused by: android.database.sqlite.SQLiteException: no such table: users: , while compiling: SELECT  * FROM users
08-08 20:31:35.367: E/AndroidRuntime(605):  at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)
08-08 20:31:35.367: E/AndroidRuntime(605):  at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:68)
08-08 20:31:35.367: E/AndroidRuntime(605):  at android.database.sqlite.SQLiteProgram.compileSql(SQLiteProgram.java:143)
08-08 20:31:35.367: E/AndroidRuntime(605):  at android.database.sqlite.SQLiteProgram.compileAndbindAllArgs(SQLiteProgram.java:361)
08-08 20:31:35.367: E/AndroidRuntime(605):  at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:127)
08-08 20:31:35.367: E/AndroidRuntime(605):  at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:94)
08-08 20:31:35.367: E/AndroidRuntime(605):  at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:53)
08-08 20:31:35.367: E/AndroidRuntime(605):  at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:47)
08-08 20:31:35.367: E/AndroidRuntime(605):  at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1671)
08-08 20:31:35.367: E/AndroidRuntime(605):  at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1645)
08-08 20:31:35.367: E/AndroidRuntime(605):  at library.DatabaseHandler.getRowCount(DatabaseHandler.java:103)
08-08 20:31:35.367: E/AndroidRuntime(605):  at library.UserFunctions.isUserLoggedIn(UserFunctions.java:71)
08-08 20:31:35.367: E/AndroidRuntime(605):  at com.example.databasetester.DashboardActivity.onCreate(DashboardActivity.java:24)
08-08 20:31:35.367: E/AndroidRuntime(605):  at android.app.Activity.performCreate(Activity.java:4539)
08-08 20:31:35.367: E/AndroidRuntime(605):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
08-08 20:31:35.367: E/AndroidRuntime(605):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2013)
08-08 20:31:35.367: E/AndroidRuntime(605):  ... 11 more

我还应该补充说,有一个名为&#34的表;用户&#34;在我的数据库中。如果你们需要我展示我的一些代码(我相信你会这样做),我会非常乐意。

1 个答案:

答案 0 :(得分:0)

这是错误:

08-08 20:31:35.367: E/AndroidRuntime(605): FATAL EXCEPTION: main
08-08 20:31:35.367: E/AndroidRuntime(605): java.lang.RuntimeException: 
  Unable to start activity
  ComponentInfo{com.example.databasetester/com.example.databasetester.DashboardActivity}:
    android.database.sqlite.SQLiteException: no such table: users: , 
  while compiling: SELECT  * FROM users

SUGGESTIONS:

1)确保你有一个表“用户”(你说你做了,但请仔细检查)

......和......

2)确保正确指定数据库文件:

  

*   SQLite Exception: no such table Error

     

如果您没有正确指定数据库文件名,我相信它   回到创建一个空数据库。这通常是原因   '找不到桌子'。检查您的路径和数据库文件名。