无法打开文件+ Android

时间:2012-07-17 13:40:35

标签: android

我已经从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);
}

0 个答案:

没有答案