在sqlite android中选择查询

Muk*_*und 4 sqlite android

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();
    }
Run Code Online (Sandbox Code Playgroud)

logcat的

android.database.sqlite.SQLiteException: near "bookpath": syntax error: , while compiling: SELECT lastchapter FROM Bookdetails INTOnothingWHERE bookpath=?
Run Code Online (Sandbox Code Playgroud)

我只想获取上述查询的结果,以便存储在lastchapter中的字符串在temp_address中可用,请帮忙

我是android sqlite数据库的新手,请帮忙

laa*_*lto 20

存在SQL语法问题,您需要使用a Cursor来检索查询结果,例如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();
Run Code Online (Sandbox Code Playgroud)