vendredi 19 février 2016

How to fully clear Android Media Storage from different application (at least on rooted device)?

I am developing application for testing another application, in this application I am inserting/editing songs/playlists in android media storage. After many inserts/deletes app gets such error:

SQLiteConstraintException: UNIQUE constraint failed: files._id (code 1555) ...

Application is trying to remove all data (now it just removes all songs/playlists) from media storage before any insert, but seems that android saves some data in media storage (all songs/playlists are removed, seems it is some meta information with specified ID in different table), so I cannot add new song with specified ID (please do not ask why I am specifying ID of entities before inserting, it is needed for testing), only

adb shell pm clear com.android.providers.media

helps here. I tried to call adb shell pm clear com.android.providers.media on rooted devices directly from application, but unfortunately it is allowed only after user approves it in dialog, but this app should work automatically, so this way does not help. Does anybody know way to solve this problem?

Aucun commentaire:

Enregistrer un commentaire