2

Are there any custom open-source libraries that don't rely on the default MediaStore (so that I don't reinvent the wheel)? Or do I have to write my own scanner? The problem:-

I've created a music player in Android that can also create playlists from local files. The details about the local media is obtained from Android's MediaStore. Everything works fine until I relocate my music files. When a media file is moved, the ID field in its entry in the Android MediaStore gets changed. Obviously that means any attempts to get to the file using the stored (stale) ID's will fail. How do I get around this? Thanks!

Kedar Paranjape
  • 1,822
  • 2
  • 22
  • 33

1 Answers1

1

You are able to manually refresh the content of the Media library. Read this related post - I think you will find it useful!

Community
  • 1
  • 1
gilonm
  • 1,829
  • 1
  • 12
  • 22
  • I think you've misunderstood my question. My problem isn't to update the MediaStore; rather my dependence on the ID field to uniquely identify a local music file. When it's moved to a different folder, this ID is lost! In other words, I need a way to find that file again using the old ID! – Kedar Paranjape Feb 02 '14 at 18:21
  • My apologies, now I understand. From what I know, there is no obvious way to control the ID given by MediaStore. If you need to keep track of your media file, why not use it's unique title or unique byte-length? the chances that two songs have the exact same byte-length are next-to-nothing... – gilonm Feb 03 '14 at 06:17
  • Yes I guess the size is definitely an attribute, probably in conjunction with other attributes, that I should use to match/recover such orphaned songs. Looks like this is gonna be as good an answer to my question as there can be. Accepting! – Kedar Paranjape Feb 03 '14 at 16:36
  • Yes, this is what I've been using so far on my app, it *is* possible to query by duration & byte-length. However, you should take into account that from device to device the reported "duration" can slightly vary for the exact same file (which is a problem if you need to synchronize + re-scan playlists from device to device). – droid256 Oct 10 '18 at 17:45