在android的sqlite的选择查询android、sqlite

由网友(错过世界遇见你)分享简介:String temp_address="nothing";try{String selectQuery = "SELECT lastchapter FROM Bookdetails INTO"+temp_address+"WHERE bookpath=?";db.execSQL(selectQuery, new St...
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();
阅读全文

相关推荐

最新文章