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
android.database.sqlite.SQLiteException: near "bookpath": syntax error: , while compiling: SELECT lastchapter FROM Bookdetails INTOnothingWHERE bookpath=?
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
i am new to android sqlite database please help
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();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With