Make directories in files internal storage

与世无争的帅哥 提交于 2019-12-05 07:51:19

问题


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:


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


来源:https://stackoverflow.com/questions/10872588/make-directories-in-files-internal-storage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!