Method for obtaining music file information through mediastore in Android

The Android system provides mediascanner, mediaprovider, mediastore and other interfaces, and provides a set of database tables to users through the content provider. When the mobile phone is powered on or an SD card is plugged in or out, the system will automatically scan the media files on the SD card and the mobile phone memory, such as audio, video, pictures, etc., and put the corresponding information into the defined database table. In this program, we don't need to care about how to scan the files in the mobile phone, just know how to query and use this information.

Mediastore defines a series of data tables. Through the query interface provided by contentresolver, we can get all kinds of required information. Let's focus on querying the music file information on the SD card. Let's first understand the query interface of contentresolver:

Song name: mediastore.audio.media.titl

Album name of the song: mediastore.audio.media.album

Singer name of the song: mediastore.audio.media.artist

Full path of song file: mediastore.audio.media.data

Release date of song file: mediastore.audio.media.year

Total playing time of Songs: mediastore.audio.media.duration

Size of song file: mediastore.audio.media.size

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>