我尝试以这种方式挂载扩展文件:
final StorageManager storageManager = (StorageManager) getSystemService(STORAGE_SERVICE);
String obbPath = Environment.getExternalStorageDirectory() + "/Android/obb";
final String obbFilePath = obbPath + "/com.example/main.1.com.example.obb";
storageManager.mountObb(obbFilePath, "SecretKey", new OnObbStateChangeListener() {
@Override
public void onObbStateChange(String path, int state) {
super.onObbStateChange(path, state);
if (state == OnObbStateChangeListener.MOUNTED) {
onObbMounted();
} else {
Log.d("##", "Path: " + path + "; state: " + state);
}
}
});
但在运行时我得到状态 21: ERROR_COULD_NOT_MOUNT:
Path: /storage/sdcard0/Android/obb/com.example/main.1.com.example.obb; state: 21
我已经添加了这个:
File f = new File(obbFilePath);
if (!f.exists()) {
Log.e("OBB", "FILE NOT FOUND!!!");
}
logcat 说该文件存在。我不知道,为什么我可以得到这个状态 21?