我已经从http://code.google.com/p/picview-for-android/下载了源代码并尝试在 Eclipse 中运行它。但 LogCat 显示
External Storage: /mnt/sdcard
DB Path: /mnt/sdcard/data/picview/accounts_followed.db
(14) cannot open file at line 30174 of [00bb9c9ce4]
(14) os_unix.c:30174: (13) open(/mnt/sdcard/data/picview/accounts_followed.db) -
Failed to open database '/mnt/sdcard/data/picview/accounts_followed.db'.
android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database
……………………
AbstractPicViewDatabase.java 包含以下代码。我认为,问题只出在这个班级的某个地方。请帮忙。
protected static SQLiteDatabase getUsableDataBase(String dbName, String sqlCreateQuery) {
File dbFile = getPathToDb(dbName);
File fileDirectory = new File(dbFile.getParent());
if (!fileDirectory.exists()) {
// Make sure the path for the file exists, before creating the
// database.
fileDirectory.mkdirs();
}
Log.d(TAG, "DB Path: " + dbFile.getAbsolutePath());
boolean initDb = !dbFile.exists();
try {
SQLiteDatabase result = SQLiteDatabase.openOrCreateDatabase(dbFile, null);
if (initDb) {
result.execSQL(sqlCreateQuery);
}
return result;
} catch (SQLiteException ex) {
Log.w(TAG, "Could not open or image database.");
return null;
}
}
/**
* Returns a file for the data base with the given name.
*/
protected static File getPathToDb(String dbName) {
String sdCardPath = Environment.getExternalStorageDirectory()
.getAbsolutePath();
Log.d(TAG, "External Storage: " + sdCardPath);
return new File(sdCardPath + File.separator + "data" + File.separator
+ PicViewConfig.APP_NAME_PATH + File.separator + dbName);
}