Make directories in files internal storage

2019-04-03 04:37发布

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.

1条回答
男人必须洒脱
2楼-- · 2019-04-03 04:58

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
查看更多
登录 后发表回答