My app uses the DownloadManager to download files to a subdirectory of the device's Music folder.
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
...
File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC) + "/MyStuff/song.mp3");
request.setDestinationUri(Uri.fromFile(file));
I have noticed that the files are being deleted when the app is uninstalled from a device running Marshmallow (this is not happening on older OS versions). Do you have any ideas about this?
Thanks
Select “Clear data” and/or “Clear cache.” Depending on the app, there may also be a “Manage data” option to clear additional settings and data. For instance, a browser app may have this option to delete bookmarks and stored passwords.
Press and hold the app icon. Then, hit "Remove." Next, choose between "Delete App" and "Remove from Home Screen." Deleting an app will erase all its data.
If you uninstall an android app, you lose both the app and it's data as well. Learn why android doesn't store the data and make re-install so difficult.
This is done by an internal class called DownloadReceiver and defined in the com.android.providers.downloads
package manifest
<receiver android:name=".DownloadReceiver" android:exported="false">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
<action android:name="android.intent.action.UID_REMOVED" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MEDIA_MOUNTED" />
<data android:scheme="file" />
</intent-filter>
</receiver>
Here the android.intent.action.UID_REMOVED
action catches the eye. It was introduced in Lollipop triggering a call to handleUidRemoved()
performing
resolver.delete(ALL_DOWNLOADS_CONTENT_URI, Constants.UID + "=" + uid, null);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With