BBYR Achieve
返回信息流
这是一条镜像帖。来源:北邮人论坛 / mobile-terminal-at / #32804同步于 2016/12/20
该镜像源已超过 30 天没有更新,可能在源站已被删除。
MobileTerminalAT机器人发帖

【已解决】android怎么按主键查询信息?

bupt033
2016/12/20镜像同步4 回复
主键名字:_id 类型:integer primary key 自己瞎试了各种格式,还是查不出来 通过『我邮2.0』发布
订阅后,新回复会通过你的通知中心匿名送达。
4 条回复
dss886机器人#1 · 2016/12/20
sql语句没有什么不一样吧。。
bupt033机器人#2 · 2016/12/20
【 在 dss886 的大作中提到: 】 : sql语句没有什么不一样吧。。 这是建表语句: create table dict(_id integer primary key autoincrement , name , pages, rank) //这种没查出来 Cursor cursor = dbHelper.getReadableDatabase().rawQuery("select * from dict where _id=1",null); //没查出来 //转换成整型 long i = Integer.parseInt(key); // 跟据id查询 Cursor cursor = dbHelper.getReadableDatabase().rawQuery( "select * from dict where _id like ?", new String[]{"%"+i+"%"}); //没查出来 //转换成整型 long i = Integer.parseInt(key); // 跟据id查询 Cursor cursor = dbHelper.getReadableDatabase().rawQuery( "select * from dict where _id = ?", new String[]{i+""}); //没查出来 //转换成整型 long i = Integer.parseInt(key); // 跟据id查询 Cursor cursor = dbHelper.getReadableDatabase().rawQuery( "select * from dict where _id = "+i, null); //这种也试过 //转换成整型 long i = Integer.parseInt(key); // 跟据id查询 Cursor cursor = dbHelper.getReadableDatabase().query("dict", // table name null, // columns "_id=" + i , null,null,null,null // selection ); 把i改成过int,Integer,long,都试过。
bupt033机器人#3 · 2016/12/20
【 在 dss886 的大作中提到: 】 : sql语句没有什么不一样吧。。 问题解决了。自己坑自己了!前面那个变量i有问题。
icyfox机器人#4 · 2016/12/27
用点ORM吧,别自己写了