Reputation: 7682
There are a tonne of questions about where to store data on Android and I don't want to duplicate any of those. This article gives some starting points to answer this question:
https://developer.android.com/guide/topics/data/data-storage.html
Most other articles are telling me to put files here: System.Environment.SpecialFolder.Personal
But, I need other apps to be able to access the file. Which folder should I choose so that I can navigate to the folder from a file explorer on Android, or be able to copy the file to my Windows machine via USB.
I tried the folder System.Environment.SpecialFolder.CommonApplicationData at random, but the app errored and I wasn't able to write the file.
Essentially, all I am asking is: which folder can I write to in an Android app that I can easily get to from outside the application? I'm happy to add permissions. This is mainly for debugging purposes right now.
Upvotes: 0
Views: 974
Reputation: 12170
Store your files in External Storage by getting the external storage path with Environment.ExternalStorageDirectory.AbsolutePath
.
Example:
public class FileStorage
{
public string MyExternalFolder
{
get
{
return Path.Combine(Android.OS.Environment.ExternalStorageDirectory.AbsolutePath, "MyAppFolder");
}
}
public void SaveToExternalStorage(string fileName, string content)
{
var filePath = Path.Combine(MyExternalFolder, fileName);
File.WriteAllText(filePath, content);
}
}
Upvotes: 2