Access the Android Special Folder Path by using Environment

后端 未结 1 1755
不知归路
不知归路 2020-11-29 13:09

I want to save my logs to a folder which I can access with windows explorer. For example I want to create my log in the following path

This PC\\Galaxy A5 (2017)\\Pho

相关标签:
1条回答
  • 2020-11-29 13:57

    You are looking for the root of GetExternalFilesDir, just pass a null:

    Example:

    var externalAppPathNoSec = GetExternalFilesDir(string.Empty).Path;
    

    Note: This is a Context-based instance method, you can access it via the Android application context, an Activity, etc... (see the link below to the Android Context docs)

    • Shared storage may not always be available, since removable media can be ejected by the user. Media state can be checked using Environment.getExternalStorageState(File).

    • There is no security enforced with these files. For example, any application holding Manifest.permission.WRITE_EXTERNAL_STORAGE can write to these files.

    re: https://developer.android.com/reference/android/content/Context#getExternalFilesDir(java.lang.String)

    0 讨论(0)
提交回复
热议问题