0

How do i make directories in internal storage?

I tried this:

File file = getFilesDir();

this makes me goes to folder "/data/data/com.mypackages/files/"

Then i want to make a folder again in that directories, let's say i want to make "myfiles" folder in there so it becomes, "/data/data/com.mypackages/files/myfiles/".

Can anyone tell me how?

I also tried this:

File file = getDir("myfiles", MODE_PRIVATE);

It makes the folder, but it was created with "app_", so the directories becomes "/data/data/com.mypackages/app_myfiles". I don't want that because i can't read the folder if it has "app_" in there.

kyuu
  • 237
  • 3
  • 7
  • 15

1 Answers1

2

The solution is under your eyes :D

m_applicationDir = new File(this.getFilesDir() + "");
m_picturesDir = new File(m_applicationDir + "/pictures");

With this code, i save in m_applicationDir the dir of the package (in your case the dir saved in file). Then simply create a sub-directory named pictures.

So m_picturesDir points to:

/data/data/com.mypackages/files/pictures
Davide Lorenzi
  • 348
  • 2
  • 6
  • 1
    Thanks for that help. Can you make a tiny example on how I can save a File (a image) to that sub-folder? I have a hard time putting together the pieces. – Dominik Jul 24 '16 at 21:06