It started as a general user question on Android forums. However, it became, of necessity, a programming issue. Here is my problem.
Android has a service - MediaScanner - that runs in the background at any time (I think), the SD card is not mounted and is installed again. This service collects data about all the media files on the map and provides SQLite DB that can be requested by music applications. Most music apps use this service because it saves battery power associated with scanning an SD card.
Since I started using android, I constantly had a problem where M3U playlists synchronized with the device remain in this SQLite DB even after deleting from the SD card. This went so far that I now have a collection of approximately 40 playlists that appear in any music application that I use, despite the fact that there are only about 10 m3u files on the map. The rest of the playlists do not play, and they are empty. I can delete them manually by deleting them from the music application, but I'm tired of it. There must be a better way to remove these ghost playlists.
There are two applications on the Android Market - SDRescan and Music Scanner, which supposedly do just that, but none of them work.
I started writing my own application to update or delete the MediaStore database and start from scratch, but I'm not very far away. I have an Android app that runs the following code:
sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory())));
I found some examples of this code online as a way to scan an SD card, but I had no luck with that. Any tips?
FULL CODE:
package com.roryok.MediaRescan; import android.app.Activity; import android.content.Intent; import android.content.IntentFilter; import android.net.Uri; import android.os.Bundle; import android.os.Environment; public class MediaRescan extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory()))); setContentView(R.layout.main); }
android mediastore
roryok Jul 21 '10 at 14:11 2010-07-21 14:11
source share