Below is my code and the workflow as I now understand. Firstly to store a file in the Local shared folders you have to create an asset, in my case its a photo and creates a file in the DCIM folder. Then, to store it in an album I use MediaLibrary.createAlbumAsync(albumName, asset, false); which requires the asset as an argument. When the flag is set to false in this command, it tries to delete the file/asset in the DCIM folder and it always asks me for permissions on my android phone which is undesirable.
Also when switching to save an audio recording and the flag is set to false I get the following error: [Error: Could not get albums: need WRITE_EXTERNAL_STORAGE permission.]
Any help would be appreciated.
const perms=await MediaLibrary.requestPermissionsAsync();
if (perms.granted){
const asset = await MediaLibrary.createAssetAsync(fileUri)
const album = await MediaLibrary.getAlbumAsync(albumName);
if (album == null){
try {
await MediaLibrary.createAlbumAsync(albumName, asset, false);
} catch (error) {
}
}
else{
await MediaLibrary.addAssetsToAlbumAsync(asset, album, false);
}
}