Device storage path


Hi guys i creat an apps that stores pdf file on device storage and it makes a problem.
before it stores pdf file it always check folder to store it. when it has folder it do nothing but if it doesnt have folder it creates the folder in this case my folder is /storage/emulated/0/Kumper.
android 5 and below device storage always begin with /storage/emulated/0/ but for android 6 and above it always begin with /sdcard/
so my question is how to know that device storage begin /sdcard/ or begin with /storage/emulated/0/ ???
thanks for any advance.


Consider using the cross-platforms abstraction to access the device storage, so you don’t have to try to remember device paths. -


i cant find any example to access device storage without knownFolder.


What’s wrong with using knownFolders to access the array of all accessible paths?


There’s nothing wrong with knownFolder but i need to access local storage not application storage. Known folder give access to application storage. Cmiiw


Then you could use fileSystem.Folder.fromPath(android.os.Environment.getExternalStoragePublicDirectory(android.os.Environment.DIRECTORY_DCIM).getAbsolutePath()) to browse the sdcard contents, specific to android of course.


Thanks bro. I gonna check it out…


thanks broo it work and i debug the apps and the real problem is permission. this is my great note for my first year become android developer. make sure you got the permission before access feature in mobile apps.


A rooky mistake, one that you eventually get used to making ever so often on Android. Check out nativescript-permissions plugin to help you request permissions prior to accessing certain functionalities.


Hi @Peter, your method returned in my device is the device internal path. I am using android 5.1.1, and my sd card path should be /storage/sdcard1.
When I ‘hardcode’ file path to it, such as

let sdPath: fs.Folder = fs.Folder.fromPath("/storage/sdcard1");

I can only get entity’s name/lastModified etc. But can read/write to test file.
Any ideas?
Thank you