public static async Task WriteFileToSharedStorageSampleAsync() { // Ask the user to grant the privacy permissions at runtime var permission = await PrivacyPermissionService.RequestAsync(PrivacyPrivilege.MediaStorage); if (permission != PrivacyPermissionStatus.Granted) { // The permission is not granted return; } if (SharedStorageService.Writable) { // Store a file in public directory so that other apps can access the file var directory = SharedStorageService.GetDirectory(Tizen.System.DirectoryType.Downloads); var path = Path.Combine(directory, "sample.txt"); File.WriteAllText(path, "Hello World!"); } }
public static async Task RequestPrivacyPermissionSampleAsync() { // Note that privileges must be declared manually in manifest // More details at https://docs.tizen.org/application/dotnet/guides/security/requesting-permissions // Check whether the app has the permission if (PrivacyPermissionService.Check(PrivacyPrivilege.MediaStorage) == PrivacyPermissionStatus.Granted) { // the permission has already been granted return; } // Ask the user for the permission PrivacyPermissionStatus permission = await PrivacyPermissionService.RequestAsync(PrivacyPrivilege.MediaStorage); if (permission != PrivacyPermissionStatus.Granted) { // The permission is not granted } }