Forum Discussion
RecoveryVR
6 years agoProtege
Accessing local files
Hi all,
I'm looking to store video files locally on the Quest and access them from the apk through their file path.
To be clear, I'm trying to access the internal storage on the Quest via an installed apk. This would be a video stored in the movies folder or something similar that can be viewed inside the Quest through the Gallery. I am aware that the file path of the apk is available and looks something like /storage/emulated/0/Android/data/com.company.name/files but this is not what I need.
I am aware of obb expansion files but we are simply using too many external files to fit inside the size constraints of an apk + obb (approx. 7GB). This app will not be pushed to the store either so I'm not worried about any of those constraints, we will hopefully be using the enterprise edition.
Any help would be greatly appreciated!
EDIT: Solved
I'm looking to store video files locally on the Quest and access them from the apk through their file path.
To be clear, I'm trying to access the internal storage on the Quest via an installed apk. This would be a video stored in the movies folder or something similar that can be viewed inside the Quest through the Gallery. I am aware that the file path of the apk is available and looks something like /storage/emulated/0/Android/data/com.company.name/files but this is not what I need.
I am aware of obb expansion files but we are simply using too many external files to fit inside the size constraints of an apk + obb (approx. 7GB). This app will not be pushed to the store either so I'm not worried about any of those constraints, we will hopefully be using the enterprise edition.
Any help would be greatly appreciated!
EDIT: Solved
17 Replies
- AnonymousHi. RiddleSystem.
Try use path /sdcard/my_folder/my_file
And don't forget about permissions: READ/WRITE in AndroidManifest.xml
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
If I am correct understood You .) - RecoveryVRProtegeThanks for your response.
Yes, sorry, I did forget to mention that I've updated the android manifest with those permissions.
Unfortunately the sdcard path doesn't seem to work either, does the Quest definitely use the same path as the Go?
I've tried a path similar to the first one because it made sense with the file structure you can see when you connect the Quest to a computer: "/storage/emulated/0/Movies/file.mp4". I'm really running out of ideas here, I feel like there is a simple solution that I'm missing :( - AnonymousHi.
This is strange.
Make sure after install app permissions: WRITE/READ are granted
adb shell dumpsys package <package_name>
And check sections:
requested permissions:
install permissions:
android.permission.READ_EXTERNAL_STORAGE: granted=true
runtime permissions:
If granted=false
adb shell pm grant <package_name> android.permission.READ_EXTERNAL_STORAGE
adb shell pm grant <package_name> android.permission.WRITE_EXTERNAL_STORAGE
And check again:
adb shell dumpsys package <package_name>
For my apps used path /sdcard/my_folder and read/write files work perfect on Oculus Go / Quest. - RecoveryVRProtegeThat was it!
Thank you so much for your help! That was driving me crazy.
Before I manually grant read/write permissions the dumpsys says
requested permissions:
android.permission.WRITE_EXTERNAL_STORAGE
android.permission.READ_EXTERNAL_STORAGE
If I'm requesting permission but it's not being granted does this mean that my android manifest is incorrectly set up ?
Here's what my manifest looks like:<?xml version="1.0" encoding="utf-8"?><manifestxmlns:android="http://schemas.android.com/apk/res/android"package="com.unity3d.player"xmlns:tools="http://schemas.android.com/tools"android:installLocation="preferExternal"><supports-screensandroid:smallScreens="true"android:normalScreens="true"android:largeScreens="true"android:xlargeScreens="true"android:anyDensity="true"/><applicationandroid:theme="@style/UnityThemeSelector"android:icon="@mipmap/app_icon"android:label="@string/app_name"><activity android:name="com.unity3d.player.UnityPlayerActivity"android:label="@string/app_name"><intent-filter><action android:name="android.intent.action.MAIN" /><category android:name="android.intent.category.LAUNCHER" /></intent-filter><meta-data android:name="unityplayer.UnityActivity" android:value="true" /></activity></application><uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /><uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /></manifest>This is in the Plugins/Android folder in the Unity project that is merged with Unity's default manifest.
Thanks again for your help! - AnonymousI am glad to help. Enjoy!
- wntrkwlExplorerSorry to revive an old thread, but does anyone know if there's a way to grant these permissions without running the adb shell pm grant command?
We deploy our apps directly to the quests for our exhibitions but the team that sideloads the .apk doesn't want to have to run these commands after each install.
Is there any way to grant these permissions via the AndroidManifest or inside of Unity itself?
+1 on this solution works, when I ran those commands my app could then load images and videos from the local storage of the Quest, so that's nice that it works but now we're looking to automate the process.
Thanks for sharing and in advance if you have any further insights. - AnonymousHi. winterkewl. Try set in AndroidManifest.xml
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="21" /> - RecoveryVRProtegeAdding that line to manifest doesn't seem to get around this, they still appear in requested permissions but not runtime. The best I could find out, this is because read/write privileges are classified as dangerous permissions and as such need to be acknowledged by the user. i.e., when you first launch an application and you get a pop up asking to allow oculus to use the microphone (if it uses the oculus avatar stuff), when you click allow that is running a command to grant android.permission.RECORD_AUDIO . I believe that you would need to set up something similar with your application to ask the user to allow read/write permissions.
Manually allowing permissions works for my purposes (so thanks once again cnn_id) as if it is done once, all updates proceeding that will still retain the same permissions as long as they have the same package name (com.name.name)- Anonymous
Did you figure anything out for this?
I'm having an issue when I set minimum Android level to 23 (as required by Oculus' servers)--the video expansion files that used to play now do not. I'm requesting read/write external in my manifest. Highest installed Android is 29 if that makes any difference.
- jynxiwinExplorer
You may need to use this path - Application.persistentDataPath
- FUTCHonored GuestSorry for reviving this thread again, but is there a way to keep the permissions for a package permanent? When I build my apk in unity and load it onto the oculus with adb I have to do adb pm grant for both storage permissions manually again. This is a bit annoying, is there a way to set the permissions to be permanent for a certain package name?
- urko.sanchezHonored Guest
Hello,
I've been having this same problem for a few days. I have a project where I show 360º videos. They were working correctly a few weeks ago and now they are not. I think I'm having problems with the access permissions to read the videos inside the "/storage/emulated/0/Videos" that I put manually through a string. Any suggestions to try to fix the problem?- Anonymous
It looks like adding android:requestLegacyExternalStorage="true" to the manifest allows the traditional method of accessing the file system to work.
Sadly, my problems have not stopped there. Especially if you're using AVPro, you might find this ongoing thread between me and RenderHeads informative: https://github.com/RenderHeads/UnityPlugin-AVProVideo/issues/776
- iXperientialMediaHonored Guest
That did it for me! Thanks!
I am able to play files from the path:
/storage/emulated/0/IXM/Dennis_V2_Export_360FOV_60fps_TB_25_sec.mp4
where IXM is a folder I created on the Quest 2 storage, same level as Android, Downloads or Movies.
This is the full custom manifest I used:
<?xml version="1.0" encoding="utf-8" standalone="no"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" android:compileSdkVersion="29" android:compileSdkVersionCodename="10" android:installLocation="auto" package="REDACTED" platformBuildVersionCode="29" platformBuildVersionName="10"><supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:smallScreens="true" android:xlargeScreens="true"/><uses-feature android:glEsVersion="0x00030000"/><supports-gl-texture android:name="GL_KHR_texture_compression_astc_ldr"/><uses-permission android:name="android.permission.INTERNET"/><uses-permission android:name="android.permission.RECORD_AUDIO"/><uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/><uses-feature android:name="android.hardware.microphone" android:required="false"/><uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/><uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/><uses-feature android:name="android.hardware.touchscreen" android:required="false"/><uses-feature android:name="android.hardware.touchscreen.multitouch" android:required="false"/><uses-feature android:name="android.hardware.touchscreen.multitouch.distinct" android:required="false"/><uses-feature android:name="android.hardware.vr.headtracking" android:required="true" android:version="1"/><uses-feature android:name="oculus.software.handtracking" android:required="false"/><uses-permission android:name="com.oculus.permission.HAND_TRACKING"/><uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/><application android:allowBackup="false" android:extractNativeLibs="true" android:icon="@mipmap/app_icon" android:label="@string/app_name" android:networkSecurityConfig="@xml/network_sec_config" android:requestLegacyExternalStorage="true"><activity android:configChanges="keyboard|keyboardHidden|navigation|orientation|screenLayout|screenSize|uiMode" android:hardwareAccelerated="false" android:launchMode="singleTask" android:name="com.unity3d.player.UnityPlayerActivity" android:screenOrientation="landscape" android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"><intent-filter><action android:name="android.intent.action.MAIN"/><category android:name="android.intent.category.LAUNCHER"/><category android:name="com.oculus.intent.category.VR"/></intent-filter><meta-data android:name="unityplayer.UnityActivity" android:value="true"/><meta-data android:name="android.notch_support" android:value="true"/><meta-data android:name="com.oculus.vr.focusaware" android:value="true"/><meta-data android:name="android.notch_support" android:value="true"/></activity><meta-data android:name="unity.splash-mode" android:value="0"/><meta-data android:name="unity.splash-enable" android:value="true"/><meta-data android:name="notch.config" android:value="portrait|landscape"/><meta-data android:name="unity.build-id" android:value="f9d86e1d-da2b-4f34-ac63-2b099cfad14d"/><meta-data android:name="com.samsung.android.vr.application.mode" android:value="vr_only"/><meta-data android:name="com.unity.xr.oculus.LowOverheadMode" android:value="false"/><meta-data android:name="com.oculus.supportedDevices" android:value="quest|quest2"/><meta-data android:name="com.oculus.handtracking.frequency" android:value="LOW"/></application></manifest>
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 6 months ago
- 1 year ago
- 2 years ago
- 1 month ago