问题描述
我正在尝试从存在且具有所需值的 sqlite 数据库中读取数据。出于某种原因,游标不返回任何内容或执行停止 - 我不知道原因是什么,因为没有任何类型的错误。 打印后似乎没有任何反应(在 logcat 中):
TableAllSyncInBoxHandlerThread:handleMessage():从 TABLE_ALL
代码:
db = db_helper.getReadableDatabase();
String[] projection_id = {
BaseColumns._ID,SpamBusterContract.TABLE_ALL.COLUMN_CORRES_INBox_ID
};
String selection_id = null;
String[] selection_args = null;
String sort_order = SpamBusterContract.TABLE_ALL.COLUMN_SMS_EPOCH_DATE + " DESC";
Log.d(TAG,"TableAllSyncInBoxHandlerThread: handleMessage(): reading values from TABLE_ALL");
------> Cursor cursor_read_id = db.query(SpamBusterContract.TABLE_ALL.TABLE_NAME,// The table to query
projection_id,// The array of columns to return (pass null to get all)
selection_id,// The columns for the WHERE clause
selection_args,// The values for the WHERE clause
null,// don't group the rows
null,// don't filter by row groups
sort_order // The sort order
);
if (!cursor_read_id.movetoFirst()) {
tableall_is_empty = true;
Log.d(TAG,"TableAllSyncInBoxHandlerThread: handleMessage(): TABLE_ALL is empty");
} else {
tableall_is_empty = false;
Log.d(TAG,"TableAllSyncInBoxHandlerThread: handleMessage(): TABLE_ALL not empty");
}
cursor_read_id.close();
可能是什么原因?
编辑:得到了答案。愚蠢的我!我在代码的其他部分在该表上启动了一个事务。我写了 db.beginTransaction()
却忘了结束。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)