I’m writing an Android project in Eclipse and running it on a 3.1 tablet.
When I try to fetch a line from my SQLite database with
int Get(long rowId){
System.out.println("Works up to here!!!"); //things are fine
Cursor c = myDbHelper.fetch(rowId); //things are not fine
...
}
I get the following in logcat:
Works up to here!!!
threadid=9: thread exiting with uncaught exception (group=0x40142760)
FATAL EXCEPTION: Thread-10
java.lang.NullPointerException
at blah blah blah...
And when I debug, that same spot gives me
The JAR file ...\android.jar has no source attachment.
I find neither of these messages helpful. My code works right up until the above line, but doesn’t go into fetch() in my DataBaseHelper class. I know that the class (including open(), create(), fetch(), and all that) works because it’s from http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/ and I wrote another program with the same database file using the same DataBaseHelper class.
Short of posting my 900 lines of code for someone to go through and help me out, what should I look for that might be causing this problem?
Of course, it was a stupid little mistake. I had two “myDbHelper”s. Fixed that and now it works!