2016-09-27 216 views
-4

一般問題:我有數據庫應用程序(它創建數據庫並允許向其中輸入數據)。在仿真器(Nexus 7 API 22 Android 5.0.2)上運行時,運行良好,但同一應用在真實設備上運行時華碩AOSP On Flo Android 5.1.1 API 22崩潰。在其他真實設備上運行應用程序索尼E5823 Android 6.0.1 API 23它運行良好。在真實設備上運行應用程序vs模擬器

編輯:

logcat的輸出:

09-27 08:57:50.318 544-572/? I/ActivityManager: Displayed com.linux.site.mrt.mydatabaseexample/.MainActivity: +467ms 09-27 08:57:50.341 894-894/? I/LatinIME: Starting input. Cursor position = -1,-1 09-27 08:57:50.355 894-894/? E/RichInputConnection: Unable to connect to the editor to retrieve text. 09-27 08:57:50.355 894-894/? D/RichInputConnection: Will try to retrieve text later. 09-27 08:57:50.359 894-894/? I/InputAttributes: InputType.TYPE_NULL is specified 09-27 08:57:50.407 894-894/? I/LatinIME: Starting input. Cursor position = 0,0 09-27 08:58:01.265 10240-10240/? E/SQLiteLog: (1) no such table: results_table 09-27 08:58:01.267 10240-10240/? D/AndroidRuntime: Shutting down VM 09-27 08:58:01.268 10240-10240/? E/AndroidRuntime: FATAL EXCEPTION: main Process: com.linux.site.mrt.mydatabaseexample, PID: 10240 android.database.sqlite.SQLiteException: no such table: results_table (code 1): , while compiling: select * from results_table 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.SQLiteQuery.<init>(SQLiteQuery.java:37) at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44) at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1316) at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1255) at com.linux.site.mrt.mydatabaseexample.DatabaseHelper.getAllData(DatabaseHelper.java:128) at com.linux.site.mrt.mydatabaseexample.MainActivity$2.onClick(MainActivity.java:80) 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) 09-27 08:58:01.270 544-1123/? W/ActivityManager: Force finishing activity 1 com.linux.site.mrt.mydatabaseexample/.MainActivity

+1

你能告訴我們locgat嗎? – adalPaRi

+0

我懷疑你是在資產文件夾中創建數據庫並訪問它。你必須動態地創建數據庫/表。這是所有三星設備或任何修改操作系統的設備的常見問題 – kgandroid

+0

@kgandroid數據庫是在數據/數據中創建的/packageName...or應該被創建。我正在使用'db.execSQL(創建表「+ TABLE_NAME +(...'代碼 – cheeroke

回答

0

屁股在logcat中看出,TABEL tabel_Result沒有在數據庫中找到,如果存儲在模擬器你清晰的數據,會出現同樣的錯誤。我想你需要

+0

準確地說[這是](http://stackoverflow.com/questions/9862949/cant-create-database-in-android)是正確的解決方案。 – cheeroke

相關問題