尝试从本地db文件(最好是SD卡)加载数据。
在执行任何操作之前,我首先检查是否已安装SD卡。
url: function(params) {
return '/some/url/' + params.term;
},
这基本上会调用崩溃应用程序的代码部分。
if (isExternalStorageWritable()) {
loadFile(SharedPref.getDBPath(this), new DataLoaderCallback() {
@Override
public void onDataRetrieved(ImportModel importModel) {
}
});
}
这是错误:
private SQLiteDatabase connect() {
String dbPath = SharedPref.getManifestPath(mContext);
File dbfile = new File(dbPath);
if (dbfile.exists()) {
return SQLiteDatabase.openDatabase(dbfile.getAbsolutePath(), null, SQLiteDatabase.OPEN_READWRITE);
}
return null;
}
当我使用时:
Failed to open database '/storage/sdcard1/Alarms/data/manifest'.
android.database.sqlite.SQLiteException: not an error (code 0): Could not open the database in read/write mode.
at android.database.sqlite.SQLiteConnection.nativeOpen(Native Method)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:212)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:196)
at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:463)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:185)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:177)
at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:806)
at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:791)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:694)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:669)
它确实有效,但我只能从文件中读取。我想读写。因此, return SQLiteDatabase.openDatabase(dbfile.getAbsolutePath(), null, SQLiteDatabase.OPEN_READONLY);
。
该文件具有读写权限,我在清单中添加了此权限。
OPEN_READWRITE
我该如何解决这个问题?