在android的sqlite的选择查询 [英] select query in sqlite android
本文介绍了在android的sqlite的选择查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
String temp_address="nothing";
try
{
String selectQuery = "SELECT lastchapter FROM Bookdetails INTO"+temp_address+"WHERE bookpath=?";
db.execSQL(selectQuery, new String[] { fileName });
System.out.println(temp_address+" result of select Query");
}
catch(Exception e)
{
System.out.println(e+" is the error here");
}
finally
{
db.close();
}
logcat的
Logcat
android.database.sqlite.SQLiteException: near "bookpath": syntax error: , while compiling: SELECT lastchapter FROM Bookdetails INTOnothingWHERE bookpath=?
我只想把上面的查询的结果,使存储在lastchapter字符串在temp_address可用
请大家帮忙
i just want to take the result of the above query so that the string stored in lastchapter is available in temp_address please help
我是新至Android SQLite数据库,请帮助
i am new to android sqlite database please help
推荐答案
有SQL语法的问题,你就需要使用光标
来检索查询结果,对例如使用 rawQuery()
:
There are SQL syntax problems and you'll need to use a Cursor
to retrieve query results, for example with rawQuery()
:
String selectQuery = "SELECT lastchapter FROM Bookdetails WHERE bookpath=?";
Cursor c = db.rawQuery(selectQuery, new String[] { fileName });
if (c.moveToFirst()) {
temp_address = c.getString(c.getColumnIndex("lastchapter"));
}
c.close();
这篇关于在android的sqlite的选择查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文