为什么getExternalStorageDirectory()mkdir()返回false?

时间:2015-10-20 20:28:57

标签: android permissions

我哪里错了?

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.qwerty.client">

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>

<uses-feature android:name="android.hardware.camera" android:required="false"/>
<uses-feature android:glEsVersion="0x00020000" android:required="true"/>

<supports-screens android:xlargeScreens="true"/>

<application android:allowBackup="true" ...

并在活动中:

String dirPath = Environment.getExternalStorageDirectory().toString() + "/TEST/";
File dir = new File(dirPath);
boolean res = dir.mkdir();

mkdir()在我的Nexus5上返回false

我的gradle文件

android {
  compileSdkVersion 23
  buildToolsVersion "23.0.1"

为什么mkdir()会返回false?我的错误在哪里?

0 个答案:

没有答案