- Home /
Upload/Download user files Android/IOS,
I am trying to create an app which generates binary data that can be exported / imported, it can then be shared and used by other users that have the same app. A few questions on various forums are asking similar but not exactly what I am looking for.
I am able to save and read files to the persistentDataPath, but this is not easy for the user to find this directory and find the file.
Ideally i would like to save or move the file to the "general download" area of the android/IOS. - IS THIS EVEN POSSIBLE?
I have been experimenting with System.Environment.SpecialFolder trying various locations but on the android env it will not allow me to save a file anywhere but in the app data area (persistentDataPath).
I have enabled the write permissions in the building settings for "External (SD Card)" - as a side note android forums describe this not as a physical external SD card but as an external memory area from the app area. - so now installing the app on android it asks for permision to access media area of the device - which is good. But i still can't seem to write to any area.
Here is a summation of the code i am trying to use:
byte[] content;
// add data to content here
string destination = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments);
string fullPath = System.IO.Path.Combine(destination, "TestFile.txt");
System.IO.File.WriteAllBytes(fullPath, content);
Works fine on windows env, but not Android if i don't use persistentDataPath, I have yet to test on ios
Another option I am looking into is to save the file in the persistentDataPath and then trying to use native plug in to share the file eg with Mail or Whatsapp, but so far I cannot find a plugin that supports general file attachments.
For background - Unity 5.5.4f1 Android APK 24
Thanks for any hints /help in advance.
,
Your answer
Follow this Question
Related Questions
File Read-Write Error in iOS 1 Answer
is it possible to access the IOS file system 0 Answers
Using OS specific API 1 Answer
Admob Memory Issues 0 Answers
Native camera FOV? 0 Answers