访问到内OBB扩展文件中的文件 [英] Accessing to files inside obb expansion file

查看:964
本文介绍了访问到内OBB扩展文件中的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我下面的所有正式文件扩展导游,但我无法找到它。我无法访问我需要的载OBB文件。

我在一个zip文件中需要6个音频文件(80MB),我存储(uncom pressed),并更名为main.2001.test.expansion.proj.obb,并存储在到/ mnt / SD卡/安卓/ OBB / test.expansion.proj /

我会尝试访问该文件

 字符串mainFileName = Helpers.getExpansionAPKFileName(这一点,真,2001年);
如果(!Helpers.doesFileExist(这一点,mainFileName,27959282L,FALSE))
{
    //下载
} 其他 {
    Log.d(test_file里面,文件存在);
}

子presourceFile expansionFile = APKExpansionSupport.getAPKExpansionZipFile(这一点,2001,2001);
如果(expansionFile!= NULL)
{
    ZipEntryRO []齐罗= expansionFile.getAllEntries();
    对于(ZipEntryRO项:齐罗){
        Log.d(test_files_zip,文件名fileZip:+ entry.getZipFileName());
        尝试{
            AssetFileDescriptorロ= entry.getAssetFileDescriptor();
            Log.d(test_files_zip,--fileZip getfiledescriptor.tostring:+ ro.getFileDescriptor()的toString());
            Log.d(test_files_zip,--fileZip createinputstring.tostring:+ ro.createInputStream()的toString());

            AssetFileDescriptor assetFileDescriptor = expansionFile.getAssetFileDescriptor(entry.getZipFileName()+/ audio02.mp3);
            如果(assetFileDescriptor!= NULL){
                Log.d(test_files_mp3,长度+ assetFileDescriptor.getLength()); //检查它的存在
            }
        }赶上(IOException异常E){Log.e(test_exp,IoExcp:+ e.getMessage()); }
    }
}
 

在 -​​ > assetFileDescriptor = expansionFile.getAssetFileDescriptor(.....);我已经尝试了所有我figuret出来,在不同的地方找到,但我无法获取文件。 有没有什么办法让从它的名字的文件,如果它的Zip文件里?

应用程序应发挥的specificorder这些文件,我们不希望以解压缩文件,并让他们,大众。


编辑。回答对自己

找到了,那是个我不明白,当我首先看它或我只是错过了。

 子presourceFile expansionFile = APKExpansionSupport.getAPKExpansionZipFile(这一点,2001,2001);
如果(expansionFile!= NULL){
        的FileDescriptor FD = expansionFile.getAssetFileDescriptor(audio_01.mp3);
        //要么
        InputStream的是= expansionFile.getInputStream(audio_01.mp3);
    }
 

解决方案

由于Aarolama Bluenk建议,这里的答案code(repited)

找到了,那是个我不明白,当我首先看它或我只是错过了。

 子presourceFile expansionFile = APKExpansionSupport.getAPKExpansionZipFile(这一点,2001,2001);
如果(expansionFile!= NULL){
        的FileDescriptor FD = expansionFile.getAssetFileDescriptor(audio_01.mp3);
        //要么
        InputStream的是= expansionFile.getInputStream(audio_01.mp3);
}
 

I'm following all official expansion files guides, but i can't find it. I'm unable to access the contained obb file i need.

I need 6 audio files (80Mb) that i "stored" (uncompressed) in a zip file and renamed as 'main.2001.test.expansion.proj.obb' and stored in '/mnt/sdcard/Android/obb/test.expansion.proj/'

I'll try to access to the files

String mainFileName = Helpers.getExpansionAPKFileName(this,true,2001);
if(!Helpers.doesFileExist(this, mainFileName, 27959282L, false))
{
    //download
} else {
    Log.d("test_file","file exist");
}

ZipResourceFile expansionFile = APKExpansionSupport.getAPKExpansionZipFile(this,2001,2001);
if(expansionFile!=null)
{
    ZipEntryRO[] ziro = expansionFile.getAllEntries();
    for (ZipEntryRO entry : ziro) {
        Log.d("test_files_zip", "fileZip filename: "+entry.getZipFileName());
        try{
            AssetFileDescriptor ro = entry.getAssetFileDescriptor();
            Log.d("test_files_zip", "--fileZip getfiledescriptor.tostring: "+ro.getFileDescriptor().toString());
            Log.d("test_files_zip", "--fileZip createinputstring.tostring: "+ro.createInputStream().toString());

            AssetFileDescriptor assetFileDescriptor = expansionFile.getAssetFileDescriptor(entry.getZipFileName()+"/audio02.mp3");
            if(assetFileDescriptor!=null) {
                Log.d("test_files_mp3", "length: "+assetFileDescriptor.getLength()); //checking it exists
            }
        }catch (IOException e){ Log.e("test_exp","IoExcp: "+e.getMessage()); }
    }
}

In -> assetFileDescriptor = expansionFile.getAssetFileDescriptor(.....); i've tried all i figuret out and found in different places, but i was unable to take the file. Is there any way to get the file from its name if it's inside the zip?

The app should play these files in an specificorder and we don't want to unzip the files and make them ""public"".


Edited. Answer to myself

Found, it was a line i didn't understand when i firstly read it or i simply miss it.

ZipResourceFile expansionFile = APKExpansionSupport.getAPKExpansionZipFile(this,2001,2001);
if(expansionFile!=null){
        FileDescriptor fd = expansionFile.getAssetFileDescriptor("audio_01.mp3");
        //or
        InputStream is = expansionFile.getInputStream("audio_01.mp3");
    }

解决方案

As Aarolama Bluenk suggested, here's the answer code (repited)

Found, it was a line i didn't understand when i firstly read it or i simply miss it.

ZipResourceFile expansionFile = APKExpansionSupport.getAPKExpansionZipFile(this,2001,2001);
if(expansionFile!=null){
        FileDescriptor fd = expansionFile.getAssetFileDescriptor("audio_01.mp3");
        //or
        InputStream is = expansionFile.getInputStream("audio_01.mp3");
}

这篇关于访问到内OBB扩展文件中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆