I am using Xamarin.Android and I want to save a .txt
file to the SD card. Here is the code that I am using:
private void SavetoSd()
{
If file does not exist first create, than get the absolute path and write your data into it.
Java.IO.File sdCard = Android.OS.Environment.ExternalStorageDirectory;
Java.IO.File dir = new Java.IO.File (sdCard.AbsolutePath + "/MyFolder");
dir.Mkdirs ();
Java.IO.File file = new Java.IO.File (dir,"iootext.txt");
if (!file.Exists ()) {
file.CreateNewFile ();
file.Mkdir ();
FileWriter writer = new FileWriter (file);
// Writes the content to the file
writer.Write (jsonData);
writer.Flush ();
writer.Close ();
}