简体   繁体   中英

Android device internal storage full path

I am making AR video playback app. I want to play video from device storage instead of include it in the app. In the path field in video texture I should write the path of the internal storage. I wrote "/storage"emulated/0/Demo.mp4" (video's name is Demo) It works on the testing device, but when I try running the app on other device it does not work because the path differs (internal path is :/storage/sdcard0) What is the path should I wrote in the video texture to ensure running the app whatever the device is?

To find locations on internal storage for your app, use getFilesDir() , called on any Context (such as your Activity, to get a File object.

To get a location on external storage unique for your app, use getExternalFilesDir() , called on any Context (such as your Activity, to get a File object.

To get a standard location on external storage for common types of files (eg, movies), use getExternalStoragePublicDirectory() on Environment.

To get the root of external storage, use getExternalStorageDirectory() on Environment. This, however, is considered sloppy programming nowadays, as it encourages developers to just put files in random locations.

Hardcoding things is not the best way but you could check if the video exists in

 /sdcard
 /mnt/sdcard
 /storage/sdcard0
 /storage/emulated/0
 /storage/emulated/legacyode

at least those are the most common places for android devices. Then set the patch programatically instead of using the inspector

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM