Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/212.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 无法打开文件+;安卓_Android - Fatal编程技术网

Android 无法打开文件+;安卓

Android 无法打开文件+;安卓,android,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_followe

我已经从下载了源代码,并试图在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);
}

创建数据库时,请确保已授予适当的权限是否在模拟器上运行?您可能需要转到AVD设置,并确保为SD卡定义至少几兆字节的空间。