Creating a directory in internal memory (root folder)

I am trying to create a directory in the internal memory of a device ...

I did like this:

File testDir = new File(Environment.getRootDirectory(),"Sample");
    testDir.mkdir();

But I do not see the folder created in the DDMS file explorer when I run it in the emulator. I also added

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

to the manifest file. Add something else ... Is this correct? If no plz, suggest me the correct procedure.

+3
source share
3 answers

You cannot write to the root of the internal storage from the SDK application.

+6
source

The only way to write in any folder that you want in the internal sotrage will be with a built-in phone. Moreover, this is a very bad idea. Why would you want to do that?

EDIT: , . Android, , .

0

You can use the getDir () function to open (if exists) or create a directory.

0
source

Source: https://habr.com/ru/post/1784054/


All Articles