简体   繁体   English

我已经挂载了我的.obb文件,但如何获得资产的最终路径

[英]I have mounted My .obb file, but how to get the final path to my assets

i have mounted an obb file and i got a path like this /mnt/obb/880f5ef6a6885d1b8937f9625be73850 , but how to get the final path to my assets ( myAssets folder in the .obb file)? 我已经安装了一个obb文件,并且得到了这样的路径/mnt/obb/880f5ef6a6885d1b8937f9625be73850 ,但是如何获取资产的最终路径(.obb文件中的myAssets文件夹)?

Also when i browse to this directory i find it empty ! 另外,当我浏览到该目录时,我发现它为

I have used this method to mount my .obb file 我已经使用此方法挂载我的.obb文件

 public void mountExpansion() {
        final StorageManager storageManager  = (StorageManager) getSystemService(STORAGE_SERVICE);



        String packageName = "com.example.android";
        String filePath = Environment.getExternalStorageDirectory()
                + "/Android/obb/" + packageName + "/" + "main."
                + xAPKS[0].mFileVersion + "." + packageName + ".obb";
        final File mainFile = new File(filePath);
        if (mainFile.exists()) {
            Log.d(TAG, "FILE: " + filePath + " Exists");
        } else {
            Log.d(TAG, "FILE: " + filePath + " DOESNT EXIST");
        }


        if (!storageManager.isObbMounted(mainFile.getAbsolutePath())) {
            if (mainFile.exists()) {
                if(storageManager.mountObb(mainFile.getAbsolutePath(), null,
                        new OnObbStateChangeListener() {
                            @Override
                            public void onObbStateChange(String path, int state) {
                                super.onObbStateChange(path, state);
                                Log.d("PATH = ",path);
                                Log.d("STATE = ", state+"");
                                expansionFilePath =   storageManager.getMountedObbPath(path);
                                if (state == OnObbStateChangeListener.MOUNTED) {
                                    expansionFilePath = storageManager
                                            .getMountedObbPath(path);
                                    Log.d(TAG,expansionFilePath+"-->MOUNTED");

                                } 
                                else {
                                    Log.d(TAG, "Path: " + path + "; state: " + state);
                                }
                            }
                        }))
                {
                    Log.d(TAG,"SUCCESSFULLY QUEUED");
                }
                else
                {
                    Log.d(TAG,"FAILED");
                }

            } else {
                Log.d(TAG, "Patch file not found");
            }
        }else {

        }





    }

I have this message on the log 我在日志中有此消息

FILE: /storage/sdcard0/Android/obb/com.example.android/main.1014001.com.example.android.obb Exists
SUCCESSFULLY QUEUED
/mnt/obb/880f5ef6a6885d1b8937f9625be73850-->MOUNTED

Thanks. 谢谢。

obbPath = Environment.getExternalStorageDirectory().getPath() + File.separator + "Android/obb/" + getPackageName() + File.separator + "main.3." + getPackageName() + ".obb";
storageManager = (StorageManager)getApplicationContext().getSystemService(Context.STORAGE_SERVICE);
m_filePathString = storageManager.getMountedObbPath(obbPath) + File.separator + filename;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在资源文件夹中获取图像的字符串路径 - How can I get a string path of an image in my assets folder 如何为我的Android项目创建.obb文件? - How to create .obb file for my android project? 我在哪里放置OBB文件来测试Nexus 4上的Android扩展包文件(OBB)? - Where to I place the OBB file to test Android Expansion Pack Files (OBB) on my Nexus 4? 如何调试我的应用程序,其中 OBB 扩展包已替换为 PAD(播放资产交付)? - How do I debug my app in which OBB Expansion Packs have been replaced with PAD (Play Asset Delivery)? 如何获得文件所在的真实路径? - How can I get the true path where my file is? 如何从我的资产文件夹中访问 a.docx 文件? - How do I access a .docx file from my assets folder? 我可以在应用程序中使用.obb文件,即使该文件小于50 mb? - Can I use .obb file in my app even if it's below 50 mb? 如何在Android首次运行应用程序时将文件从我的资产文件夹复制到我的SD卡? - How can I copy a file from my assets folder into my SD card at first run of the app in Android? 我在尝试打开资产文件夹(android)中的链接文件时遇到文件未找到异常 - I get file not found exception trying to open a linked file in my assets folder (android) Graphhopper-从已安装的obb文件系统错误加载路由信息 - Graphhopper - Loading routing information from a mounted obb file system error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM