如何将请求的结果存储在表中
你好 我想将请求的结果存储在表中。我想要该方法的结果是表 如何做到这一点?我的代码包含错误。
public array getResult_libelle(int id)
{
array tab[] = null;
try
{
Cursor c = null;
c = db.rawQuery("select libelle from favori where _id="+id, null);
c.moveToFirst();
tab = c.getString(c.getColumnIndex("libelle"));
c.close();
}
catch(Exception e)
{
e.printStackTrace();
}
return tab;
}
hi
I want to store the result of request in a table. I want the result of the method is table howa to do that? My code contains error.
public array getResult_libelle(int id)
{
array tab[] = null;
try
{
Cursor c = null;
c = db.rawQuery("select libelle from favori where _id="+id, null);
c.moveToFirst();
tab = c.getString(c.getColumnIndex("libelle"));
c.close();
}
catch(Exception e)
{
e.printStackTrace();
}
return tab;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先,您的光标已经只有名为
libelle
的列,因此我认为不需要显式地将其过滤掉。我想,你应该直接使用 getString(i) 来从游标中逐一获取每一行的数据,
尝试一下。
First of all, your cursor will already be having only the column named
libelle
so I don't think there should be a need to explicitly filter it out.I guess, you should directly use
getString(i)
to get data of each row out, one by one, from the cursorgive that a try.