- Home /
How to get Internal storage in any Android device
hello i saw a lot of topics about this but none helped me. I need to get the path "storage/emulated/0/" called "internal memory" which is the main path of internal memory in android. I mean the default for each device. if it is possible? I mean the c # code. because I would like to create a folder eg "myApplication" there and create files there
@Rageeye have you solved the problem?? I am also looking for the solution
No, but I know you have to get or write a plugin to unity that interacts with android and its something called PER$$anonymous$$ISSION
Permissions: https://developer.android.com/reference/android/$$anonymous$$anifest.permission
(full list) https://gist.github.com/Arinerron/1bcaadc7b1cbeae77de0263f4e15156f
How to: https://stackoverflow.com/questions/5819847/how-to-add-write-to-file-permission-on-android
How to get root path: https://stackoverflow.com/questions/12027830/get-android-device-emulator-root-directory#12027918
[Android] How to get the each directory path https://gist.github.com/granoeste/5574148
Answer by xxmariofer · Jan 04, 2021 at 10:36 AM
I think you are a little bit confused, since all the statements posted bellow are incorrect, you dont need to write a plugin to "interact" with permisions. you can add the manifest (is a simple xml file) manually. some of the permisions like the one you are asking for like internal storage are located in the player settings menu so there is no need to use a custom manifest, third storage/emulated/0 is already the path, you dont need to find anything else, all phones path is storage/emulated/0 and last, dont create folders arround all directories of the user device, is a really bad practice. if you want to create a folder "myApplication" simply use the persistentdatapath in unity that is located in "/storage/emulated/0/Android/data//files"
Ok, but we want to get root path by the command line like "getExternalStorageDirectory()" , not the string "storage/emulated/0", becouse the main path may make a difference on some mobile devices.
The tittle of the question is "get Internal storage" and has nothing to do with the getExternalStorateDirectory. But here is an answered question in that topic
Hello @xxmariofer, I have the same problem. When I ran my code on the virtual phone which was created in Genymotion, I could get the path (/storage/emulated/0/...) and open the files in this path correctly. But when I ran my code on the 'real phone', I could get the correct path but I couldn't open the files. I am using android phone 11. Do you have any suggestion? Thanks in advance.
how are you opening the files? what exactly happens? it returns an error? could you share the code?
I opened text files on a virtual phone (android 6) but I cannot open them on a real phone (android 11). This is my code:
path = Application.persistentDataPath; string[] folder = path.Split(char.Parse("0")); path = folder[0] + "0/WaterNet"; ghichu.text = path; if (Directory.Exists(path)) { Xulynet_dropdown.captionText.text = "Folder Exit"; } else { Directory.CreateDirectory(path); Xulynet_dropdown.captionText.text = "Create folder"; }
In this code, I check folder named 'WaterNet' is in the android storage or not. If it doesn't exist, I create a new folder named 'WaterNet'. When I added this code 'Directory.CreateDirectory(path)', it didn't work. Do you know how another way to create a new folder more correctly?
Your answer
![](https://koobas.hobune.stream/wayback/20220613005132im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Android: Writing persistent data to SD Card 2 Answers
What is most efficient way to store 'high scores' in game in unity? 1 Answer
Where is the persistent data path on my Android phone? 3 Answers
Android file path? 0 Answers
I need to set the path for saving the pictures with an application for Android and IOS 2 Answers