I am making an audio player app with MAUI (.Net-8.0) and obviously need to access the device's folders. For example, Android has /Internal storage/Music/ folder and I want to access the .mp3 files in it.
As far as I know, I need to ask for permissions to read the device's files. So in AndroidManifest.xml, under permissions, I checked the READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE.Then in the MainPage.xaml.cs I wrote:
protected override async void OnAppearing()
{
base.OnAppearing();
var status = await Permissions.CheckStatusAsync<Permissions.StorageRead>();
if (status != PermissionStatus.Granted)
{
status = await Permissions.RequestAsync<Permissions.StorageRead>();
}
if (status == PermissionStatus.Granted)
{
musicPath = GetMusicPath();
}
else
{
// TODO: not granted permission
}
}
public string GetMusicPath()
{
return Environment.GetFolderPath(Environment.SpecialFolder.MyMusic);
}
If I Debug.WriteLine(musicPath) i get "data/user/0/com.companyname.appname/files/Music", which I'm assuming is not what I'm looking for because I can't find my files (which I have in "/Internal storage/Music/"). I'm sorry if this is a dumb question but me and my friend have spent more than 3 days on this and can't seem to find anything about it on the internet.