I have a pre-made SQLite database that I am downloading from the net via an AsyncTask. It downloads the file and stores it on the sdcard in /data/databases/ I have checked the database file and it is successfully downloading and has all the appropriate tables and data but every time I try and open the database and display the stored data I get the following
03-19 18:43:10.204: E/AndroidRuntime(3057): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ondrovic.downloader/com.ondrovic.downloader.Main}: android.database.sqlite.SQLiteException: no such table: beers: , while compiling: SELECT * FROM beers ORDER BY _id
which makes no sense because the table is there
maybe my databasehelper class is wrong or I am calling it wrong.
here is my database.java
package com.ondrovic.downloader;
import java.io.File;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.os.Environment;
public class Database extends SQLiteOpenHelper{
//File rDIR = Environment.getExternalStorageDirectory();
private static String DBPATH = "/data/databases/BOOMBOZZ/";
private static String DBNAME = "boombozz.db";
private static int DBVER = 1;
private SQLiteDatabase db;
private final Context dbContext;
public Database(Context context) {
super(context, DBNAME, null, DBVER);
this.dbContext = context;
}
public void open() {
String myPath = DBPATH + DBNAME;
db = SQLiteDatabase.openDatabase(Environment.getExternalStorageDirectory() + myPath, null, SQLiteDatabase.OPEN_READWRITE);
}
public synchronized void close() {
db.close();
super.close();
}
@Override
public void onCreate(SQLiteDatabase db) {
// TODO Auto-generated method stub
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// TODO Auto-generated method stub
}
}
And here is where I am calling it in my main class
db = (new Database(this)).getWritableDatabase();
Any suggestions?
Thanks