简体   繁体   中英

Android ContentResolver.query and Custom Columns

I want to make an Android App that includes a list of audio files with extra info from each file's ID3 tag.

I currently use ContentResolver.query to get the audio files. The ID3 data I want is not part of the common, queryable information, so once I get the filename I'll need to extract it myself.

My question is how to add that extra information to the cursor? I understand that I can't change the cursor structure. Can I add more columns in advance and fill the data later? Do I have to clone all the data to a new data structure of my own?

Itai.

It sounds like your are reading audio file information from the built-in media database. In that case there is no way you can add this information to the cursor.

But you can get the extra information in your cursor-reading loop and put it and the information from the cursor into an object that will contain both.

If you are looking to use this with a CursorAdapter to fill a list view, there is no good way to put this information together.

Some possibilities:

  1. Read the ID3 tag info when you bind the view in your adapter - this means you will be doing extra processing in the UI thread which may slow your app down.

  2. Copy the information from the your cursor to your own database along with the ID3 tag information and read it from there the next time around - this means you will have repeating information of a potentially large size.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM