KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have no solid background of synchronization. I think this issue will be fixed when I use synchronized method. But can anyone help me to fix this issue? Code is below: public HashMap<String, FriendInfo> getAllRecordsInList_HashMap() { MySQLiteHelper dbHelper = MySQLiteHelper.getInstance(mActivity); HashMap<String, FriendInfo> list_map = new HashMap<String, FriendInfo>(); SQLiteDatabase db = dbHelper.getReadableDatabase(); // Cursor cursor = db.rawQuery("SELECT * from " + // dbHelper.tbl_friendlist, new String[] {}); String[] cols = { dbHelper.id, dbHelper.name, dbHelper.picture, dbHelper.birthday, dbHelper.livein, dbHelper.gender, dbHelper.is_online, dbHelper.is_vip }; Cursor cursor = db.query(dbHelper.tbl_friendlist, cols, null, null, null, null, dbHelper.name); if (cursor != null && cursor.getCount() > 0) { // some code here.... } cursor.close(); return list_map; } Different threads can call this method getAllRecordsInList_HashMap() . Please advise how to fix this issue if I make synchronized method. Will it be fixed? java.lang.IllegalStateException: Cannot perform this operation because the connection pool has been closed. at android.database.sqlite.SQLiteConnectionPool.throwIfClosedLocked(SQLiteConnectionPool.java:962) at android.database.sqlite.SQLiteConnectionPool.waitForConnection(SQLiteConnectionPool.java:599) at android.database.sqlite.SQLiteConnectionPool.acquireConnection(SQLiteConnectionPool.java:348) at android.database.sqlite.SQLiteSession.acquireConnection(SQLiteSession.java:894) at android.database.sqlite.SQLiteSession.executeForCursorWindow(SQLiteSession.java:834) at android.database.sqlite.SQLiteQuery.fillWindow(SQLiteQuery.java:62) at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:143) at android.database.s
Tags (comma-separated)
Save Edits
Cancel