Issue
I am using my own SQLite3 database as opposed to creating a new one each time my app runs, as I have a few tables with static data that I am trying to display. I created my database and placed it in my assets folder. I then created my database helper and when I start my app I can open my database without problem but when I try to open my first table using the following code
private Cursor getData()
{
try
{
myDbHelper = new DatabaseHelper(this);
SQLiteDatabase db = myDbHelper.getReadableDatabase();
Cursor cursor = db.query("exhibitor", FROM, null, null, null,null, ORDER_BY);
startManagingCursor(cursor);
return cursor;
}
catch(SQLiteException e)
{
String err = e.toString();
return null;
}
}
It throws an error saying android.database.sqlite.SQLiteException: no such table: exhibitor: , while compiling: SELECT _id, EXHIBITOR FROM exhibitor ORDER BY EXHIBITOR
but when I check the database exhibitor is there.
What am I missing?
Solution
Have you moved the database from the assets folder to /data/data/YOUR_PACKAGE/databases/
on the emulator?
This is a good detailed post about moving the database to /data/data/YOUR_PACKAGE/databases/
if it does not exist.
Here is another short and simple solution to it.
Answered By - SteD
Answer Checked By - Gilberto Lyons (JavaFixing Admin)