-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MediaStorePlugin.saveFile add .mp3 to file and not delete existing file (API 29) #4
Comments
Did you add this in the manifest ? <uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE" <!-- To read all files until API level 32 -->
android:maxSdkVersion="32" />
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE" <!-- To write all files until API level 29. We will MediaStore from API level 30 -->
android:maxSdkVersion="29" />
<application
---------------------------
android:requestLegacyExternalStorage="true">
<!-- Need for API level 29. Scoped Storage has some issue in Android 10. So, google recommanded to add this. -->
<!-- Read more from here: https://developer.android.com/training/data-storage/shared/media#access-other-apps-files-->
</application> |
Yes |
Just have tested it with my device (API 29). Couldn't reproduce. |
Maybe a problem with my API29 emulator? |
Yes, I think so. Can you manage to test with a real device? Then we can be sure about this. |
Unfortunately, I don't have a real device with API 29. |
This is an edge case. In your case, there is no record of your file in the media store internal db (That's why the log says i.e. |
Facing the same issue on API 33, any plans on implementing this fix @SNNafi ? Edit: I found a dirty workaround far from perfect, which prevents me from opening a PR, but at least it works: First I force MediaStore to scan the file using the await mediaStore.getUriFromFilePath(path: filePath).then((uri) async {
await mediaStore.deleteFileUsingUri(
uriString: uri.toString(),
forceUseMediaStore: true,
);
}); The only problem is that after accepting the popup to modify the file, the action isn't performed (I have to call it again). Will try to investigate this further. |
I am checking this now. How did you reproduce this? @KyleKun |
It will also create duplicate files If you don't have read permission. In this case, the plugin can't check for existing files. |
@Fifut, How did you reproduce this? |
There is deleteFile({required String fileName, required DirType dirType, required DirName dirName, String? relativePath}) → Future<bool> function to delete a file. (The doc text is wrong. I will update it.) BUT Do you understand the MediaStore API? There is no directory called Songs in MediaStore collections. Here are the directories that are available with MediaStore API. https://developer.android.com/training/data-storage/shared/media You can't use any other directory with MediaStore API besides these directories. |
However, there is a method called Then you can use |
Hello!
MediaStorePlugin.saveFile add .mp3 to file and not delete existing file. Instead, create a new file with (1) on the name.
Only on API 29. No problem on API 29 to 33
Here the log:
The text was updated successfully, but these errors were encountered: