android查询数据库查询不到数据,不知道为什么

ZSQ_ANDROID 2013-04-27 04:17:45
String[] columns = { "content", "optionA", "optionB", "optionC",
"optionD" };
String selection = "examSubject='" + ll_a
+ "' and chapter=? and type=? and difficult=? and num=?";
String[] selectionArgs = { "1", "1", "1", "10001" };
Cursor cursor = sqldb.query("q_question", columns, selection,
selectionArgs, null, null, null);
startManagingCursor(cursor);
Log.i("nnnnnnnnnnnn", cursor.getCount()
+ "nnnnnnnnnnnnn");//显示的是0?????????????
while (cursor.moveToNext()) {
Log.i("valcontnet", cursor.getColumnIndex("content")
+ "cccccccccccc");

byte[] val = cursor.getBlob(cursor.getColumnIndex("content"));
Log.i("valcontnet", cursor.getColumnIndex("content")
+ "cccccccccccc");
byte[] vala =
cursor.getBlob(cursor.getColumnIndex("optionA"));
byte[] valb =
cursor.getBlob(cursor.getColumnIndex("optionB"));
byte[] valc =
cursor.getBlob(cursor.getColumnIndex("optionC"));
byte[] vald =
cursor.getBlob(cursor.getColumnIndex("optionD"));
try {
content.setText(new String(val, "GBK"));
opA.setText(new String(vala, "GBK"));
opB.setText(new String(valb, "GBK"));
opC.setText(new String(valc, "GBK"));
opD.setText(new String(vald, "GBK"));
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

图片上显示的是从数据库里查找到的数据,但是在android类里就查找不到,不知道为什么,请求帮助????
...全文
384 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
ZSQ_ANDROID 2013-05-02
  • 打赏
  • 举报
回复
数据库是从外边导入的,从这个导入的数据库中查找东西,一个条件的可以查询,多条件查询就查不出数据,我用sqlite3多条件就能查出来数据,谁遇到过这样的问题
tcmakebest 2013-04-29
  • 打赏
  • 举报
回复
得先有数据才能查,呵呵
mmorss 2013-04-28
  • 打赏
  • 举报
回复
sqldb。getReadableDatabase();
hotkarriver 2013-04-28
  • 打赏
  • 举报
回复
是不是URI不对?要不试试selection里用大写的AND?

80,351

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧