Xamarin android save text file

后端 未结 3 869
Happy的楠姐
Happy的楠姐 2021-01-05 01:24

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()
  {
               


        
3条回答
  •  孤街浪徒
    2021-01-05 01:58

    If you're on Android 6.0+ you will need to perform a runtime check for permissions. This can be done like so:

    if ((CheckSelfPermission(Permission.ReadExternalStorage) == (int)Permission.Granted) && 
        (CheckSelfPermission(Permission.WriteExternalStorage) == (int)Permission.Granted))
    

    More information on this can be found in the android documentation here.

提交回复
热议问题