2013-02-25 76 views

回答

2

No.Your擴展文件的擴展文件在SD卡/ Android的下載/ obb文件夾,您需要檢索它們並解壓縮以便進一步使用它 以下是獲取擴展文件的一些代碼:

private final static String EXP_PATH =「/ Android/obb /」;

static String[] getAPKExpansionFiles(Context ctx, int mainVersion, 
     int patchVersion) { 
    String packageName = ctx.getPackageName(); 
    Vector<String> ret = new Vector<String>(); 
    if (Environment.getExternalStorageState().equals(
      Environment.MEDIA_MOUNTED)) { 
     // Build the full path to the app's expansion files 
     File root = Environment.getExternalStorageDirectory(); 
     File expPath = new File(root.toString() + EXP_PATH + packageName); 

     // Check that expansion file path exists 
     if (expPath.exists()) { 
      if (mainVersion > 0) { 
       String strMainPath = expPath + File.separator + "main." 
         + mainVersion + "." + packageName + ".obb"; 
       File main = new File(strMainPath); 
       if (main.isFile()) { 
        ret.add(strMainPath); 
       } 
      } 
      if (patchVersion > 0) { 
       String strPatchPath = expPath + File.separator + "patch." 
         + mainVersion + "." + packageName + ".obb"; 
       File main = new File(strPatchPath); 
       if (main.isFile()) { 
        ret.add(strPatchPath); 
       } 
      } 
     } 
    } 
    String[] retArray = new String[ret.size()]; 
    ret.toArray(retArray); 
    return retArray; 
} 



String[] test = getAPKExpansionFiles(myContext, 2, 0); 
     Log.d(LOG_TAG, "total file : " + test.length); 

     for (int i = 0; i < test.length; i++) 
      Log.d(LOG_TAG, "filename is : " + test[i]); 
     if (test.length > 0) { 
      try { 
       file = APKExpansionSupport.getResourceZipFile(test) 
         .getAllEntries(); 
       Log.d(LOG_TAG, "total zip file : " + file.length); 
       for (int i = 0; i < file.length; i++) { 

         Log.d(LOG_TAG, "zip filename is : " 
           + (file[i].mFileName).split("/")[1]); 

         File("/mnt/sdcard/Android/obb/one.example.expansion.downloader/main.3.one.example.expansion.downloader.obb/myvideo.mp4"); 
         File desc = new File("/mnt/sdcard/.YourFolder"); 

         ZipHelper.unzip(test[0], desc); 


       } 
      } catch (IOException e) { 
       // TODO Auto-generated catch block 
       e.printStackTrace(); 
      } 

祝你好運!

+1

實際擴展文件不提供數據安全性。因爲SD卡上的數據,所以任何人都可以訪問它,打破身份驗證規則 – User42590 2013-02-25 12:47:59

+0

嘿,我需要你的幫助 – Goofy 2013-02-26 07:18:00

+1

是@Goofy我怎麼能幫你? – 2013-02-26 08:45:25