Music Player - Problem with ContentResolver

All your problems with Audio, Video and Images.

Music Player - Problem with ContentResolver

Postby at_198x » Mon Jul 19, 2010 11:12 am

Hello everyone,
I'm developing a Music Player for Android, and I met a problem which's really annoying. I used ContentResolver to get all Media File in SD card with these code:
Code: Select all
   private Cursor getAllMediaFile() {      
      return mContext.getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, null, null, null,
              MediaStore.Audio.Media.TITLE + " ASC");
   }

and it worked like a charm. But when I deleted some media file in SD card and used these code again to update the list of media file, so superisingly it didn't work. After some time, I figured out the trick: if I close the emulator and turn it on again, these code work again. So I modified the code to:
Code: Select all
   private Cursor getAllSong() {
      ContentResolver resolver = mContext.getContentResolver();   
      
      resolver.notifyChange(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, null);      
      return mContext.getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, null, null, null,
              MediaStore.Audio.Media.TITLE + " ASC");
   }

and nothing change T_T
If anyone know how to solve this problem, please show me. Thank you very much ^_^
at_198x
Developer
Developer
 
Posts: 29
Joined: Tue Apr 27, 2010 4:48 am

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: Exabot [Bot] and 19 guests