Closed ewgcat closed 7 years ago
Problem lies on com.hengte.baolimanager.db.DBUtil.getTaskObject Line 107
报错的是Line107 cursorProjects.moveToNext()的这句代码,执行的顺序是 BriteDatabase mDB=new SqlBrite.Builder().build().wrapDatabaseHelper(new DbOpenHelper(context), Schedulers.io()); Cursor cursorProjects=mDB.query("select * from "+Project.TABLE_NAME+" where "+Project.TASKID +" = "+taskId+" order by "+ Project.POSITION); while (cursorProjects!=null&&cursorProjects.moveToNext()){} 出错的是cursorProjects.moveToNext()这句代码,网上解决办法如下: 在第一次建立sqlite连接的时候(重写了getReadabelDatabase()方法), 设置一下临时文件目录,like this: private static boolean mainTmpDirSet = false; @Override public SQLiteDatabase getReadableDatabase() { if (!mainTmpDirSet) { boolean rs = new File("/data/data/com.cmp.pkg/databases/main").mkdir(); Log.d("ahang", rs + ""); super.getReadableDatabase().execSQL("PRAGMA temp_store_directory = '/data/data/com.cmp.pkg/databases/main'"); mainTmpDirSet = true; return super.getReadableDatabase(); } return super.getReadableDatabase(); } 请大神帮忙看一下,如何解决这个问题
If you are map it to just one, just use mapToOne from QueryObservable If you are map it to List, just use mapToList from QueryObservable
It looks like you are trying to use Cursor then forget to close it.
This isn't a problem with SQL Brite. It would seem you are opening resources and not closing it somewhere.
java.lang.RuntimeException:Unable to resume activity {com.hengte.baolimanager/com.hengte.baolimanager.ui.patrol.index.PatrolCommonListActivity}: android.database.sqlite.SQLiteCantOpenDatabaseException: unable to open database file (Sqlite code 14), (OS error - 24:Too many open files) 2 android.app.ActivityThread.performResumeActivity(ActivityThread.java:3586) 3 ...... 4 cause by: 5 android.database.sqlite.SQLiteCantOpenDatabaseException:unable to open database file (Sqlite code 14), (OS error - 24:Too many open files) 6 android.database.sqlite.SQLiteConnection.nativeExecuteForCursorWindow(Native Method) 7 android.database.sqlite.SQLiteConnection.executeForCursorWindow(SQLiteConnection.java:855) 8 android.database.sqlite.SQLiteSession.executeForCursorWindow(SQLiteSession.java:851) 9 android.database.sqlite.SQLiteQuery.fillWindow(SQLiteQuery.java:62) 10 android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:143) 11 android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:132) 12 android.database.AbstractCursor.moveToPosition(AbstractCursor.java:219) 13 android.database.AbstractCursor.moveToNext(AbstractCursor.java:268) 14 com.hengte.baolimanager.db.DBUtil.getTaskObject(DBUtil.java:107) 15 com.hengte.baolimanager.ui.patrol.index.PatrolCommonListActivity.checkDateFilter(PatrolCommonListActivity.java:182) 16 com.hengte.baolimanager.ui.patrol.index.PatrolCommonListActivity.onResume(PatrolCommonListActivity.java:86) 17 android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1279) 18 android.app.Activity.performResume(Activity.java:7017) 19 android.app.ActivityThread.performResumeActivity(ActivityThread.java:3561) 20 android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3626) 21 android.app.ActivityThread$H.handleMessage(ActivityThread.java:1618) 22 android.os.Handler.dispatchMessage(Handler.java:102) 23 android.os.Looper.loop(Looper.java:156) 24 android.app.ActivityThread.main(ActivityThread.java:6524) 25 java.lang.reflect.Method.invoke(Native Method) 26 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:941) 27 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:831)
网上查的解决这个问题的链接http://blog.csdn.net/sinat_16336389/article/details/52711613,https://ahangchen.gitbooks.io/windy-afternoon/content/android/sqlite/SQLITE%E5%9C%A8ANDROID%E4%B8%8A%E7%9A%84%E4%B8%80%E4%B8%AABUG.html 谢谢,一直依赖你的项目,请帮忙解决一下吧,大神