public User find(int id)
{
db = helper.getWritableDatabase();
Cursor cursor = db.rawQuery("select mima from userdb where id =?", new String[]
{ String.valueOf(id) });
if (cursor.moveToNext())
{
return new User(cursor.getString(cursor.getColumnIndex("mima"));//这行有错误
}
return null;
}
错误提示:
Multiple markers at this line
- The constructor User(String) is
undefined
我是模仿这段代码写的,本人初学者,求大神指教
public Student find(int sid)
{
db = helper.getWritableDatabase();
Cursor cursor = db.rawQuery("select sid,name,age from t_student where sid = ?", new String[]
{ String.valueOf(sid) });
if (cursor.moveToNext())
{
return new Student(cursor.getInt(cursor.getColumnIndex("sid")), cursor.getString(
cursor.getColumnIndex("name")), cursor.getShort(cursor.getColumnIndex("age")));
}
return null;
}
错误提示是:he constructor User(String) is undefined,刚刚的忘了加一个括号
关于android数据库查询操作的问题
答案:2 悬赏:50 手机版
解决时间 2021-04-05 11:57
- 提问者网友:太高姿态
- 2021-04-04 21:43
最佳答案
- 五星知识达人网友:撞了怀
- 2021-04-04 23:16
new User(cursor.getString(cursor.getColumnIndex("mima")));最右边少了个括号吧
全部回答
- 1楼网友:第幾種人
- 2021-04-04 23:53
不要用query方法,直接用sql语句查询
select * from notes where _id = "10"
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯