I am trying to open a writeable SQLite database with this code...
public DataAdapterForServieClass open() throws SQLException {
db = DBHelper.getWritableDatabase();
return this;
}
However I am getting the following error on the db = DBHelper.getWritableDatabase();
line...
06-10 11:58:13.995: ERROR/AndroidRuntime(548): FATAL EXCEPTION: main
06-10 11:58:13.995: ERROR/AndroidRuntime(548): java.lang.StringIndexOutOfBoundsException: index=0 length=0
06-10 11:58:13.995: ERROR/AndroidRuntime(548): at android.app.ContextImpl.validateFilePath(ContextImpl.java:1518)
06-10 11:58:13.995: ERROR/AndroidRuntime(548): at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:725)
06-10 11:58:13.995: ERROR/AndroidRuntime(548): at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:221)
06-10 11:58:13.995: ERROR/AndroidRuntime(548): at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:149)
This is the code of my DBHelper
class...
static class DatabaseHelper extends SQLiteOpenHelper {
DatabaseHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
Log.w(TAG, "Upgrading database from version " + oldVersion
+ " to "
+ newVersion + ", which will destroy all old data");
db.execSQL("DROP TABLE IF EXISTS titles");
onCreate(db);
}
public void onCreate(SQLiteDatabase arg0) {
// TODO Auto-generated method stub
}
}
Could someone please help me.