我在 logcat 中通过严格模式面对大量消息。可能是这个原因,如果我点击ui上的下一个按钮,那么它需要很长时间差不多1分钟。如何发生这种情况,数据加载过程很快。但为什么得到严格的模式日志?我不知道。 最后,如何在我的4.1.6中使用严格模式。 DEVELOPER_MODE 的含义是什么? , StrictMode 详情,
logcat示例:
11-27 13:08:14.220: D/StrictMode(11010): StrictMode policy violation; ~duration=1492 ms: android.os.StrictMode$StrictModeDiskReadViolation: policy=23 violation=2
11-27 13:08:14.220: D/StrictMode(11010): at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1135)
11-27 13:08:14.220: D/StrictMode(11010): at android.database.sqlite.SQLiteConnection.applyBlockGuardPolicy(SQLiteConnection.java:1041)
11-27 13:08:14.220: D/StrictMode(11010): at android.database.sqlite.SQLiteConnection.executeForLong(SQLiteConnection.java:595)
11-27 13:08:14.220: D/StrictMode(11010): at android.database.sqlite.SQLiteConnection.setForeignKeyModeFromConfiguration(SQLiteConnection.java:281)
11-27 13:08:14.220: D/StrictMode(11010): at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:214)
11-27 13:08:14.220: D/StrictMode(11010): at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:193)
11-27 13:08:14.220: D/StrictMode(11010): at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:463)
11-27 13:08:14.220: D/StrictMode(11010): at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:185)
11-27 13:08:14.220: D/StrictMode(11010): at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:177)
11-27 13:08:14.220: D/StrictMode(11010): at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:804)
11-27 13:08:14.220: D/StrictMode(11010): at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:789)
11-27 13:08:14.220: D/StrictMode(11010): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:694)
11-27 13:08:14.220: D/StrictMode(11010): at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:952)
11-27 13:08:14.220: D/StrictMode(11010): at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:256)
11-27 13:08:14.220: D/StrictMode(11010): at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:224)
11-27 13:08:14.220: D/StrictMode(11010): at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:164)
11-27 13:08:14.220: D/StrictMode(11010): at com.project.dc.databases.DBAdapter.open(DBAdapter.java:224)
11-27 13:08:14.220: D/StrictMode(11010): at com.project.dc.activity.RunFormActivity.saveOnSwipe(RunFormActivity.java:10641)
11-27 13:08:14.220: D/StrictMode(11010): at com.project.dc.activity.RunFormActivity$34.onClick(RunFormActivity.java:2575)
11-27 13:08:14.220: D/StrictMode(11010): at android.view.View.performClick(View.java:4438)
11-27 13:08:14.220: D/StrictMode(11010): at android.view.View$PerformClick.run(View.java:18422)
11-27 13:08:14.220: D/StrictMode(11010): at android.os.Handler.handleCallback(Handler.java:733)
11-27 13:08:14.220: D/StrictMode(11010): at android.os.Handler.dispatchMessage(Handler.java:95)
11-27 13:08:14.220: D/StrictMode(11010): at android.os.Looper.loop(Looper.java:136)
11-27 13:08:14.220: D/StrictMode(11010): at android.app.ActivityThread.main(ActivityThread.java:5001)
11-27 13:08:14.220: D/StrictMode(11010): at java.lang.reflect.Method.invokeNative(Native Method)
11-27 13:08:14.220: D/StrictMode(11010): at java.lang.reflect.Method.invoke(Method.java:515)
11-27 13:08:14.220: D/StrictMode(11010): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
11-27 13:08:14.220: D/StrictMode(11010): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
11-27 13:08:14.220: D/StrictMode(11010): at dalvik.system.NativeStart.main(Native Method)
我已经遵循严格模式(logcat):http://pastebin.com/jeDa0YNA
我通过解决这个问题来解决这个问题:请你知道如何解决这个问题。
答案 0 :(得分:1)
您的应用程序正在主线程上执行数据库操作。所以你得到这个错误。
将saveonswipe
中的OnClick
来电移至AsyncTask