select query in sqlite android select query in sqlite android sqlite sqlite

select query in sqlite android


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();


The logcat said it all, you've forgot spaces. To get data into the string:

String temp_address="nothing";String[] args = new String[] { fileName };Cursor cursor = sqLiteDatabase.rawQuery("SELECT lastchapter FROM Bookdetails WHERE bookpath=?", args);if (cursor.moveToFirst()){    temp_address = cursor.getString(cursor.getColumnIndex("lastchapter"));}cursor.close();


Correct your query with below: add space at WHERE Cause

String selectQuery = "SELECT lastchapter FROM Bookdetails WHERE bookpath=? ";

Update: go with rawQuery() becoz it's return Cursor with results

 String selectQuery = "SELECT lastchapter FROM Bookdetails WHERE bookpath=? "; Cursor c = db.rawQuery(selectQuery, new String[] { fileName }); if (c.moveToFirst()) { temp_address = c.getString(0); }  c.close();

And for more information go to this: http://www.higherpass.com/android/tutorials/accessing-data-with-android-cursors/