Sto cercando di aprire un database SQLite scrivibile con questo codice ...java.lang.StringIndexOutOfBoundsException: index = 0 lunghezza = 0 nel database SQLite get
public DataAdapterForServieClass open() throws SQLException {
db = DBHelper.getWritableDatabase();
return this;
}
Comunque sto ottenendo il seguente errore sul 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)
Questo è il codice della mia classe DBHelper
...
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
}
}
Qualcuno potrebbe aiutarmi per favore.
Si prega di indicare il codice del codice categoria DBHelper –
DataAdapterForServieClass pubblici aperti() throws SQLException { db = DBHelper.getWritableDatabase(); restituisce questo; era il codice classe dbhelper, ed è dove si è verificato l'errore –
@KishorDgupta, abbiamo bisogno del codice della classe 'DBHelper', non del codice dove lo chiamate. Qual è il codice del metodo 'getWritableDatabase()' in 'DBHelper'? – wattostudios