I'm trying to select a specific row from a database based on a string in a textview. The error log when I run it appears to say that it's looking for a column, but it should be looking for a row. The error log says:
--I/Database(279): sqlite returned: error code = 1, msg = no such column: Book
--D/AndroidRuntime(279): Shutting down VM
--W/dalvikvm(279): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
--E/AndroidRuntime(279): FATAL EXCEPTION: main
--E/AndroidRuntime(279): android.database.sqlite.SQLiteException: no such column: Book: , while compiling: SELECT book, background FROM bookbackgrounds WHERE book=Book
Here's the code where it gets the string from the textview, then runs a method that is supposed to return a filename in the form of a text string, then display the returned string in a second textview:
String bkString = showBooktextview.getText().toString();
bga.open();
String newBKstring = bga.getBGforBook(bkString);
bga.close();
showDBBooktextview.setText(newBKstring);
and here's the method that the error says there's no such column with the name of that book. (it's supposed to be looking for the ROW that contains that book name):
public String getBGforBook(String bkString) {
String[] thecolumns = new String[] { KEY_BOOK, KEY_BACKGROUND };
Cursor cursor = db.query(DB_TABLE, thecolumns, KEY_BOOK + "=" + bkString, null, null, null, null);
String result = "";
if (cursor != null){
cursor.moveToFirst();
result = result
+ cursor.getString(1);
}
return null;
}
so is the method written incorrectly? If so, how to write it correctly so that it looks for a row that contains the bookname string?