在android中挂载多个obb文件

时间:2014-05-29 05:40:29

标签: android android-assets

当我将3 OBB个文件一个接一个地挂载到同一个应用程序时,它们会以不同的路径创建。之后context.getAssets()仅返回最后一个。

如何将它们安装到一个路径并拥有所有数据?

或者如何在安装后在它们之间切换?

1 个答案:

答案 0 :(得分:1)

每次成功安装后如何存储文件路径! 也许这样的事情可以做到吗?:

public String mountObbFile(String filepathToObb){
    final Sting obbMountPath;
    final StorageManager storageManager = (StorageManager) getSystemService(STORAGE_SERVICE);
    storageManager.mountObb(filepathToObb, null , new OnObbStateChangeListener() {
        @Override
        public void onObbStateChange(String path, int state) {
            super.onObbStateChange(path, state);
            if (state == OnObbStateChangeListener.MOUNTED) {

                StorageManager storage = (StorageManager) getSystemService( STORAGE_SERVICE );
                obbMountPath = storage.getMountedObbPath( obbFilePath );
            } else {
                Log.i("OBB-MOUNT" , "state: " + state); 
                obbMountPath = "ERROR";
            }
        }
    });
    return obbMountPath;
}

String mountPath1 =  mountObbFile (filepathToObb1);
String mountPath2 =  mountObbFile (filepathToObb2);
String mountPath3 =  mountObbFile (filepathToObb3);