i am trying to execute rawquery in sqlite in android but its erroring out .
My SQL code is :
String sql = "select vaccine_name,vaccine_duration from table_vaccinelists where vaccine_type=";
String[] selectionArgs = new String[10];
selectionArgs[0] = "'C'";
Cursor cur = database.rawQuery(sql, selectionArgs);
Error :
Its giving “Null pointer exception” .i am new to android and i feel there is something wrong the way i have written the where clause in the query .
Yes, there is something wrong with your query:
selectionArgsare there to replace question marks in your query.However, it shouldn’t cause NPE, so something else might be wrong. I think your
databasevariable isnull, check the way you initialise it.