如何在/Android/obb下创建文件夹? [英] How to create a folder under /Android/obb?

查看:1900
本文介绍了如何在/Android/obb下创建文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用扩展文件,但发现了一个无法解决的问题.

似乎您可以访问/Android/obb文件夹并最终删除/Android/obb/my.package.name目录(使用某些文件管理器尝试),但是我无法在应用程序中处理这种情况.

如果我只是让Google Downloader库尝试下载扩展文件,它将挂起并出错(对于丢失的文件夹),但是如果我重新创建该文件夹,它将启动.

奇怪的是,我能够从其他应用程序创建文件夹(我曾经用来查看目录的文件管理器)但不是从我的

我尝试过

File f = new File(Environment.getExternalStorageDirectory(), "Android/obb/my.package.name");
f.mkdirs();

但它不起作用.

我在清单中拥有权限:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

并且我的目标是api 23并使用api 25进行编译.

解决方案

OP将Target SDK降至22,并能够避免导致问题的危险权限工作流程.

I'm trying to use expansion files and I found an issue that I'm not able to resolve.

It seems that you can access the /Android/obb folder and eventually delete the /Android/obb/my.package.name directory (tried with some file manager), but I cannot handle this situation whithin the app.

If I just let the Google Downloader library try to download the expansion file it will hang and error (for the missing folder), but it will start if I recreate the folder.

The strange thing is that I'm able to create the folder from other apps (the same file manager that I've used to see the directory) but not from mine!

I tried with

File f = new File(Environment.getExternalStorageDirectory(), "Android/obb/my.package.name");
f.mkdirs();

but it doesn't work.

I've the permissions in the manifest:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

and I'm targeting api 23 and compiling with the 25.

解决方案

OP dropped the Target SDK to 22 and was able to avoid Dangerous permission work flow which was causing the issue.

这篇关于如何在/Android/obb下创建文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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