我正在尝试使用此代码打开一个可写的 SQLite 数据库...
public DataAdapterForServieClass open() throws SQLException {
db = DBHelper.getWritableDatabase();
return this;
}
但是我db = DBHelper.getWritableDatabase();
在线上收到以下错误...
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)
这是我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
}
}
有人可以帮助我。