I have my own database which contains http://i55.tinypic.com/6i8861.jpg (SQLiteBrowser)
I have this code, which copies the database from the assets resource folder to the system data/data/package/files directory http://pastebin.com/XeNGmrcD and this is how it is implemented into the onCreate() http://pastebin.com/TigXFStF and this is the image where the test.sqlite is placed into the emulator system dir and the error I get when I execute the query below: http://i51.tinypic.com/2mxrk0p.jpg
cursor = dbObj.getReadableDatabase().query(TABLE_NAME, null, null, null, null, null, null);
I get that cursor is null since there is no table found. If I execute the same query equivalent to the one above (SELECT * FROM gradovi) in the SQLite Browser. I get results, here I don’t.
Please tell me how can i fetch data from my database? What I’m doing wrong? Also I want to know how to iterate through the records?
It looks like the database file copying is failing. Your code has a number of swallowed exceptions, so you might not be seeing the errors that occur.
Note that trying to ship an app with a pre-built SQLite database file is wrought with pitfalls, including varying paths and varying SQLite versions.