I am trying to search my notes whose title start with "n" but i dont know whats wrong with my query i got force close error.
Here is my log:
04-01 12:19:37.833: D/AndroidRuntime(676): Shutting down VM
04-01 12:19:37.833: W/dalvikvm(676): threadid=1: thread exiting with uncaught exception (group=0x40015560)
04-01 12:19:37.913: E/AndroidRuntime(676): FATAL EXCEPTION: main
04-01 12:19:37.913: E/AndroidRuntime(676): android.database.sqlite.SQLiteException: near "%": syntax error: , while compiling: SELECT DISTINCT _id, title, body, cdate, passw FROM notes WHERE title LIKE n%
04-01 12:19:37.913: E/AndroidRuntime(676): at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)
04-01 12:19:37.913: E/AndroidRuntime(676): at android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:92)
Here is the code:
public Cursor search(String title) {
Cursor mCursor =
mDb.query(true, DATABASE_TABLE, new String[] {KEY_ROWID,
KEY_TITLE, KEY_BODY,KEY_CDATE,KEY_PASS}, KEY_TITLE + " LIKE" +" " + title + '%', null,
null, null, null, null);
if (mCursor != null) {
mCursor.moveToFirst();
}
return mCursor;
}