0

Where am I wrong?

<?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" ...

and in Activity:

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

mkdir() returns false on my Nexus5

my gradle file

android {
  compileSdkVersion 23
  buildToolsVersion "23.0.1"

Why does mkdir() return false? Where is my mistake?

S McCrohan
  • 6,663
  • 1
  • 30
  • 39
Sviatoslav
  • 1,301
  • 2
  • 17
  • 42
  • 2
    Make sure that you have [requested the runtime permissions](https://stackoverflow.com/questions/32635704/cant-get-the-permission), particularly `WRITE_EXTERNAL_STORAGE`. Also, please replace `String dirPath = Environment.getExternalStorageDirectory().toString() + "/TEST/";` with `File dir=new File(Environment.getExternalStorageDirectory(), "TEST");`. – CommonsWare Oct 20 '15 at 20:32
  • 1
    keep also in mind that `mkdir` and `mkdirs` return both false if the directory exits already – Blackbelt Oct 20 '15 at 20:38
  • Please make sure to include your actual question in the post, not just the title. – matt. Oct 20 '15 at 21:17
  • @CommonsWare, you were right about targetSDK 23. I changed it on 22 and it works! :) – Sviatoslav Oct 21 '15 at 07:31

0 Answers0