The problem was in write permisions i use the code below to check if the file exist ask for permision and change the ringtone and work
var newuri3 = Android.Net.Uri.Parse("file:///storage/emulated/0/Ringtones/" + item.ringtone);
var newuri = newuri3;
bool b = false;
if (null != newuri)
{
try
{
var inputStream = Android.App.Application.Context.ContentResolver.OpenInputStream(newuri);
inputStream.Close();
Console.WriteLine("file exist");
b = true;
}
catch (Exception e)
{
Console.WriteLine("File corresponding to the uri does not exist " + newuri.ToString());
}
}
var bi = Settings.System.CanWrite(Android.App.Application.Context);
if (bi)
{
Console.WriteLine("it haw write permision");
}
else
{
Console.WriteLine("doenst have permision");
Intent intent = new Intent(Settings.ActionManageWriteSettings);
intent.SetData(Android.Net.Uri.Parse($"package:{Android.App.Application.Context.PackageName}"));
intent.AddFlags(ActivityFlags.NewTask);
Android.App.Application.Context.StartActivity(intent);
}
RingtoneManager.SetActualDefaultRingtoneUri(Android.App.Application.Context, RingtoneType.Ringtone, newuri);
where item.ringtone is the file name for example music.mp3