Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by Railon23 · Sep 01, 2015 at 12:33 PM · androidwindowsfolderpersistentdatapathio

Saved folders (Application.persistentDataPath) showing on Android device but not in windows explorer

Hi devs,

I'm saving some files from the Application.streamingAssetsPath and copy it to the Application.persistentDataPath. Of course I do some Path.Combine() to have a better structure with folders. I use

 File.WriteAllBytes(fileToDirectory, wwwStreamingFile.bytes);

to save the file and this works. I can see the folder structure at the Android device (Nexus 4), using Astro or other File Manager Apps. All folders and files are there.

Strange thing is that I can't see the folder(s) in the windows explorer. Any idea why this can happen? I searched a lot and tried multiple things like enable/disable "development build", changing "Write Access" etc. Nothing worked.

I appreciate your input.

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Railon23 · Sep 01, 2015 at 02:33 PM 0
Share

Ok, I got another Android phone (Samsung S3) and tested it. It works on this device. When I do my copying and after a reconnection of the USB cable the folders are visible in the windows explorer. All looks good as expected.

Now the question still remains why it's not showing on the Nexus 4. I'll google for a while and see if I can find an answer for the issue.

I want the files/data be accessible by the end users, so they need to find the files on their device (best case when connected to a PC).

iOS will be another question I guess. Never looked into it if it is possible to get access to saved files.

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by djiango · Apr 06, 2017 at 12:26 PM

For anyone with the same problem.

http://answers.unity3d.com/questions/918210/storing-files-on-android-not-showing-up-on-windows.html

My implementation of the code:

 void RefreshAndroidFile(string path) //Refresh file to show up in mtp mode
 {
     if(!File.Exists(path))
         return;
 
     using (AndroidJavaClass jcUnityPlayer = new AndroidJavaClass ("com.unity3d.player.UnityPlayer"))
     using (AndroidJavaObject joActivity = jcUnityPlayer.GetStatic<AndroidJavaObject> ("currentActivity"))
     using (AndroidJavaObject joContext = joActivity.Call<AndroidJavaObject> ("getApplicationContext"))
     using (AndroidJavaClass jcMediaScannerConnection = new AndroidJavaClass ("android.media.MediaScannerConnection"))
     jcMediaScannerConnection.CallStatic("scanFile", joContext, new string[] { path }, null, null);
 }

By calling this method after your file has been created, it should show the file and folder in Windows Explorer

 string path = "/mnt/sdcard/Pictures/MyFolder/Screenshot.png"; //a path to the file
 RefreshAndroidFile(path);
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Railon23 · Sep 01, 2015 at 04:29 PM

After some more google searching I found that it's a known bug and also a workaround I need to implement next (second link, second reply).

  1. stackoverflow.com

  2. code.google.com issues

UPDATE 1: I still don't have a working solution for this problem. Any code samples are appreciated. Thanks

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

30 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Android PersistentDataPath UnauthorizedAccessException 0 Answers

Reading in from a text file (.txt) when deploying to Android devices. 0 Answers

Open Location of Application.persistentDataPath android 0 Answers

transfer data between android to Window throught a USB cable 0 Answers

Android Size Different [S5] [TAB A] 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges