我正在从Sqlite数据库中检索数据,代码工作正常,但是我在日志中遇到了此异常
打开数据库java.lang.Throwable:stacktrace 和处置数据库false java.lang.Throwable:stacktrace
我如何解决这个问题,谢谢..!
这是我的代码
String selectQuery = "SELECT * FROM " + GroupList.TABLE_NAME + " WHERE " +" ( " + whereParamOnline + " ) " + " ORDER BY " + GroupList.COLUMN_TIMESTAMP + " DESC";
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);
List<GroupList> notes = new ArrayList<>();
try
{
// looping through all rows and adding to list
if (cursor.moveToFirst()) {
do {
GroupList note = new GroupList();
note.setId(cursor.getString(cursor.getColumnIndex(GroupList.COLUMN_ID)));
note.setGroup_id(cursor.getString(cursor.getColumnIndex(GroupList.COLUMN_GROUP_ID)));
note.setName(cursor.getString(cursor.getColumnIndex(GroupList.COLUMN_NAME)));
note.setUser_id(cursor.getString(cursor.getColumnIndex(GroupList.COLUMN_USER_ID)));
note.setPicture(cursor.getString(cursor.getColumnIndex(GroupList.COLUMN_PICTURE)));
note.setNotification(cursor.getString(cursor.getColumnIndex(GroupList.COLUMN_NOTIFICATION)));
note.setTotal_member(cursor.getString(cursor.getColumnIndex(GroupList.COLUMN_TOTAL_MEMBER)));
note.setTimestamp(cursor.getString(cursor.getColumnIndex(GroupList.COLUMN_TIMESTAMP)));
notes.add(note);
} while (cursor.moveToNext());
}
cursor.close();
}
catch (Throwable e)
{
Log.d(TAG,"(getAllGroupList) catch error = "+e.getMessage().toString());
}
finally {
db.close();
}
// return notes list
return notes;
这是日志
08-17 18:52:53.156 30409-30409/com.selfie.life.selfielife D/SQLiteDatabase: Open database
java.lang.Throwable: stacktrace
at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:815)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:714)
at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:578)
at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:269)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:223)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:163)
at com.selfie.life.selfielife.SqliteDatabase.GroupList.GroupListDatabaseHelper.getAllGroupList(GroupListDatabaseHelper.java:135)
at com.selfie.life.selfielife.Fragment.MessageChat.ChatRecentFragment$8.onResponse(ChatRecentFragment.java:446)
at retrofit2.ExecutorCallAdapterFactory$ExecutorCallbackCall$1$1.run(ExecutorCallAdapterFactory.java:70)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5769)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
08-17 18:52:53.166 30409-30409/com.selfie.life.selfielife D/SQLiteDatabase: dispose database false
java.lang.Throwable: stacktrace
at android.database.sqlite.SQLiteDatabase.dispose(SQLiteDatabase.java:286)
at android.database.sqlite.SQLiteDatabase.onAllReferencesReleased(SQLiteDatabase.java:280)
at android.database.sqlite.SQLiteClosable.releaseReference(SQLiteClosable.java:74)
at android.database.sqlite.SQLiteClosable.close(SQLiteClosable.java:106)
at com.selfie.life.selfielife.SqliteDatabase.GroupList.GroupListDatabaseHelper.getAllGroupList(GroupListDatabaseHelper.java:163)
at com.selfie.life.selfielife.Fragment.MessageChat.ChatRecentFragment$8.onResponse(ChatRecentFragment.java:446)
at retrofit2.ExecutorCallAdapterFactory$ExecutorCallbackCall$1$1.run(ExecutorCallAdapterFactory.java:70)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5769)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)