{"id":5034,"date":"2019-08-18T05:08:26","date_gmt":"2019-08-17T21:08:26","guid":{"rendered":"https:\/\/unitycoder.com\/blog\/?p=5034"},"modified":"2023-05-10T13:27:14","modified_gmt":"2023-05-10T10:27:14","slug":"read-file-from-oculus-quest-sdcard-folder","status":"publish","type":"post","link":"https:\/\/unitycoder.com\/blog\/2019\/08\/18\/read-file-from-oculus-quest-sdcard-folder\/","title":{"rendered":"Read File from Oculus Quest \/sdcard\/ Folder"},"content":{"rendered":"\n<p>New 2023 (more limitations)<br><\/p>\n\n\n\n<p>&#8220;This is because the Quest OS v53 now uses Android 12, which limits the way apps can access storage. From the developers of <a rel=\"noreferrer noopener\" href=\"https:\/\/www.oculus.com\/experiences\/quest\/7830420446969757\/\" target=\"_blank\">Polysketch<\/a>:<br><br>&#8211; No Access<br>&#8212; \/sdcard\/Polysketch\/<br>&#8211; Can create folders, but not files<br>&#8212; \/sdcard\/Android\/Polysketch\/<br>&#8211; Full folder &amp; file creation<br>&#8212; \/sdcard\/Android\/Android\/data\/com.PolysketchLLC.Polysketch\/files (Application.persistentDataPath)<br>&#8212; \/sdcard\/Download\/Polysketch\/ &#8212;&#8211; not very safe as users will arbitrarily delete-all here if running out of space<br>&#8212; \/sdcard\/Documents\/Polysketch\/ &#8212;&#8211; seems like the best option. Easy user access, and we can read each other&#8217;s save locations if we wish to.<br><br>How to update &#8211;<br>Setting the flag preserveLegacyExternalStorage to true in the manifest will allow you to read &amp; write from sdcard\/whatever\/ <em>if<\/em> the app is installed as an update to an older version. On clean installs, this flag is ignored. So this flag won&#8217;t grant us access indefinitely, but will let us read old save files and move them to the new preferred spot. AndroidManifest.xml &lt;application android:requestLegacyExternalStorage=&#8221;true&#8221; android:PreserveLegacyExternalStorage=&#8221;true&#8221;><\/p>\n\n\n\n<p><strong>Source:<\/strong><br><a href=\"https:\/\/forum.unity.com\/threads\/access-to-oculus-2-local-video-images-from-unity.1434886\/#post-9004114\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/forum.unity.com\/threads\/access-to-oculus-2-local-video-images-from-unity.1434886\/#post-9004114<\/a><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/forum.unity.com\/styles\/default\/xenforo\/clear.png?ssl=1\" alt=\":p\" title=\"Stick Out Tongue    :p\"\/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p><br><\/p>\n\n\n\n<p><strong>Solution#1:<\/strong><br><br>&#8211; Place your file into some sdcard folder (by browsing there with Explorer), for example:&#8221;This PC\\Quest\\Internal shared storage\\Download\\myfile.txt&#8221;<br>&#8211; Add script to load file:<br><code>var t = File.ReadAllText(\"\/sdcard\/Download\/myfile.txt\");<\/code><br>&#8211; From Unity menu select: Oculus\/Tools\/Create store-compatible AndroidManifest.xml<br>&#8211; Modify Assets\/Plugin\/Android\/AndroidManifest.xml, add this line after &lt;\/application> :<br><code>&lt;uses-permission android:name=\"android.permission.READ_EXTERNAL_STORAGE\" \/><\/code><br>&#8211; Build &amp; Run *Note: run fails, due to missing launch action.. so run the app manually in device (from library\/unknown sources)<br>&#8211; Allow Read permissions when you start the app<\/p>\n\n\n\n<p><strong>Optional:<\/strong><br>&#8211; You can enable LAUNCHER, to make Build &amp; Run work, by replacing this line:<br><code>&lt;category android:name=\"android.intent.category.INFO\"<\/code>\/&gt;<br>with:<br><code>&lt;category android:name=\"android.intent.category.LAUNCHER\"\/&gt;<\/code><br>&#8211; Can also disable permission request (while doing tests), by modifying this line:<br><code>meta-data android:name=\"unityplayer.SkipPermissionsDialog\" android:value=\"false\" <\/code><br>into:<br><code>meta-data android:name=\"unityplayer.SkipPermissionsDialog\" android:value=\"true\" <\/code><br>&#8211; Can also add Write permissions:<br><code>&lt;uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\"\/&gt;<\/code><\/p>\n\n\n\n<p><strong>My AndroidManifest.xml:<\/strong><br><a href=\"https:\/\/gist.github.com\/unitycoder\/a8a827311ea0837b06af6ccde85effec\">https:\/\/gist.github.com\/unitycoder\/a8a827311ea0837b06af6ccde85effec<\/a><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"538\" height=\"402\" data-attachment-id=\"5037\" data-permalink=\"https:\/\/unitycoder.com\/blog\/2019\/08\/18\/read-file-from-oculus-quest-sdcard-folder\/image-2-3\/\" data-orig-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2019\/08\/image-2.png?fit=538%2C402&amp;ssl=1\" data-orig-size=\"538,402\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image-2\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2019\/08\/image-2.png?fit=300%2C224&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2019\/08\/image-2.png?fit=538%2C402&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2019\/08\/image-2.png?resize=538%2C402&#038;ssl=1\" alt=\"\" class=\"wp-image-5037\" srcset=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2019\/08\/image-2.png?w=538&amp;ssl=1 538w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2019\/08\/image-2.png?resize=300%2C224&amp;ssl=1 300w\" sizes=\"auto, (max-width: 538px) 100vw, 538px\" \/><figcaption class=\"wp-element-caption\">My Build Settings for Install location and Write Permissions (they don&#8217;t seem to affect much?)<br><strong>*UPDATE:<\/strong> Settings Write Permission to External seems to help!<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1025\" height=\"666\" data-attachment-id=\"5036\" data-permalink=\"https:\/\/unitycoder.com\/blog\/2019\/08\/18\/read-file-from-oculus-quest-sdcard-folder\/image-1-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2019\/08\/image-1.png?fit=1025%2C666&amp;ssl=1\" data-orig-size=\"1025,666\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image-1\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2019\/08\/image-1.png?fit=300%2C195&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2019\/08\/image-1.png?fit=1024%2C665&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2019\/08\/image-1.png?fit=1024%2C665&amp;ssl=1\" alt=\"\" class=\"wp-image-5036\" srcset=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2019\/08\/image-1.png?w=1025&amp;ssl=1 1025w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2019\/08\/image-1.png?resize=300%2C195&amp;ssl=1 300w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2019\/08\/image-1.png?resize=768%2C499&amp;ssl=1 768w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2019\/08\/image-1.png?resize=1024%2C665&amp;ssl=1 1024w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><\/figure>\n\n\n\n<p><strong>Solution#2:<\/strong> (temporary fix)<br><br>check what permissions the app has:<br><code>adb shell dumpsys package &lt;package_name&gt;<\/code><br>then add permissions<br><code>adb shell pm grant &lt;package_name&gt; android.permission.READ_EXTERNAL_STORAGE<\/code><strong><br><\/strong><code>adb shell pm grant &lt;package_name&gt; android.permission.WRITE_EXTERNAL_STORAGE<\/code><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"680\" height=\"509\" data-attachment-id=\"5147\" data-permalink=\"https:\/\/unitycoder.com\/blog\/2019\/08\/18\/read-file-from-oculus-quest-sdcard-folder\/image-1-7\/\" data-orig-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2020\/01\/image-1.png?fit=680%2C509&amp;ssl=1\" data-orig-size=\"680,509\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image-1\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2020\/01\/image-1.png?fit=300%2C225&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2020\/01\/image-1.png?fit=680%2C509&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2020\/01\/image-1.png?resize=680%2C509&#038;ssl=1\" alt=\"\" class=\"wp-image-5147\" srcset=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2020\/01\/image-1.png?w=680&amp;ssl=1 680w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2020\/01\/image-1.png?resize=300%2C225&amp;ssl=1 300w\" sizes=\"auto, (max-width: 680px) 100vw, 680px\" \/><figcaption class=\"wp-element-caption\">You need to get this dialog to appear, so can you can grant access (if it doesnt appear from Build &amp; Run, then close the app, start app from Library \/ unknown sources)<\/figcaption><\/figure>\n\n\n\n<p><strong>Resources:<\/strong><br>&#8211; <a href=\"https:\/\/developer.oculus.com\/distribute\/latest\/concepts\/publish-mobile-manifest\/\">https:\/\/developer.oculus.com\/distribute\/latest\/concepts\/publish-mobile-manifest\/<\/a><br>&#8211; <a href=\"https:\/\/forums.oculusvr.com\/developer\/discussion\/78412\/accessing-local-files\">https:\/\/forums.oculusvr.com\/developer\/discussion\/78412\/accessing-local-files<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>New 2023 (more limitations) &#8220;This is because the Quest OS v53 now uses Android 12, which limits the way apps can access storage. From the developers of Polysketch: &#8211; No Access&#8212; \/sdcard\/Polysketch\/&#8211; Can create folders, but not files&#8212; \/sdcard\/Android\/Polysketch\/&#8211; Full folder &amp; file creation&#8212; \/sdcard\/Android\/Android\/data\/com.PolysketchLLC.Polysketch\/files [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":5036,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[420,1],"tags":[1115,665,1116,1114,845,1113,171,960],"class_list":["post-5034","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","category-uncategorized","tag-file","tag-oculus","tag-permissions","tag-quest","tag-read","tag-sdcard","tag-unity","tag-vr"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2019\/08\/image-1.png?fit=1025%2C666&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/p1KTaT-1jc","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/5034","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/comments?post=5034"}],"version-history":[{"count":8,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/5034\/revisions"}],"predecessor-version":[{"id":5665,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/5034\/revisions\/5665"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/media\/5036"}],"wp:attachment":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/media?parent=5034"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/categories?post=5034"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/tags?post=5034"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}