0
  1. I've tried several folders but looks like no file is created. External read & write permission have been enabled. The code run without any sign of error. (as given below) Here is the screenshot of the code inside mainactivity.cs (this is for testing purposes). I also assume that since this is platform specific, the code must be in android project.

            string filename = Path.Combine(Xamarin.Essentials.FileSystem.AppDataDirectory, "count1.txt") ;
    
        StreamWriter sw = File.CreateText(filename);
        sw.WriteLine("asad ini test");
        sw.Close();enter code here
    

1b. I 'm using Android 6.0 phone, but I can't find such folder /data/user... (I'm not sure if such folder is targeted special version of Android)

I search both internal /Android/myproject/files/ and found nothing I search external SDcard /Android/myproject/files/ and still found nothing (please look at the my android phone folders, i can't even find /data folder

  1. Once, this is accomplished the next step would be how to call this function from the generalproject (non android, non IOS, non UWP project).

  2. Example to write file given in xamarin document. Where should this code reside? in general project folder ? or, android project folder?

code

enter image description here

  • 1. Essentials is cross-platform so you can use it anywhere. 2. `looks like no file is created` Have you tried reading the file back into memory, using FileExists, etc... – SushiHangover Jun 08 '20 at 03:29
  • Have you tried using this?: `var folder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); string filename = folder + "/count.txt";` – Solarcloud Jun 08 '20 at 05:03

1 Answers1

0
  1. The term "external" used in android is very misleading. It doesn't mean the external removable SD card rather some folders that don't require "root" permission. Therefore, initially I can't find the folder which I save a file into.

  2. Another reason is each phone manufacture uses different name, hence it is very difficult to get an absolute address of an external removable SD Card.

More details is explained in blog_external_removable_SD_Card

  1. You can't write to the removable SD Card an old post here