69450

Question:
I've tried to follow a tutorial on accessing sqlite databases on android and i've made it so far.
my code gets to "columns[] created" and then i get a null pointer exception...
I believe my database is populated but i have no way of really telling. can someone show me how to check? / get this working?
public Cursor getAnimalCursor() {
System.out.println("in getAnimalCursor()");
String[] columns = new String[] {"_id", "name"};
System.out.println("columns[] created");
Cursor c = myDataBase.query("animals", null, null, null, null, null, null);
System.out.println("cursor created");
return c;
}
Answer1:Check if you have initialized myDataBase. It is the cause of null pointer exception.
Answer2:You are not selecting any columns
have you tried this?
Cursor c = myDataBase.query("animals", columns, null, null, null, null, null);
<strong>Edit:</strong>
as Anirudha Agashe mention
I think the NPE occurs because he does not do open()
the sql