There are two requirements
- associate some sound properties, e.g. loudness or tempo, with every audio item on Android
- efficiently query audio items using these properties, e.g. get top most loud tracks
I query MediaStore.Audio.Media.EXTERNAL_CONTENT_URI
via ContentResolver
to get audio items and analyze their properties.
The problem is how to associate these properties with audio items - there's no additional MediaStore
table columns to keep user data.
Current solution is to create an internal database, store sound properties there and use MediaStore.Audio.Media._ID
as a key to audio items.
Therefore, in order to get top most loud tracks, I need
- query internal database and get item ids
- query
ContentResolver
usingWHERE _ID IN (...)
clause and get audio items
This may introduce performance issues in general case (long list of ids). Moreover, things get complicated when I want to sync internal database with content provider, e.g. remove property records for previously deleted audio items. There is no info about deleted items in content provider, so I need to compare all ids from two sources.
So, my concerns are:
- There's no additional
MediaStore
table columns for storing user data, correct? Compare toContactsContract.Data
. - There are problems with querying and syncing internal database with content provider. Are there ways to reduce them?
Possible solutions: