1.Android6.0之前:
6.0之前是不需要动态申请权限的,直接在manifest中申请即可以正常使用。
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.xt.client">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
...
</manifest>
代码使用
private void writeFile() throws IOException {
String absolutePath = Environment.getExternalStorageDirectory().getAbsolutePath();
File file = new File(absolutePath + File.separator + "a.txt");
if (file.exists()) {
file.delete();
ToastUtil.showCenterToast("文件存在,删除成功");
} else {
file.createNewF
android安卓12/11文件读写权限的设置
最新推荐文章于 2024-08-26 03:52:47 发布
