问题
I've googled it, searched on the official android docs, and found nothing satisfying. I'm developing music player app that has access to Media Storage and confused between _ID and AUDIO_ID.
What are the differences between those two? (if any)
回答1:
Following is difference.
_ID
The unique ID for a row.
AUDIO_ID
The ID of the audio file
Difference
_ID is column name of BASECOLUMNS database table. It is implemented in following other tables.
Browser.BookmarkColumns, Browser.SearchColumns, CalendarContract.Attendees, CalendarContract.CalendarAlerts, CalendarContract.CalendarEntity, CalendarContract.Calendars, CalendarContract.Colors, CalendarContract.ColorsColumns, CalendarContract.Events, CalendarContract.EventsEntity
And AUDIO_ID is part of MediaStore.Audio.AudioColumns, which has implementation of BASECOLUMNS table.
MediaStore.Audio.AudioColumns : Columns for audio file that show up in multiple tables.
Reference : _ID , AUDIO_ID
回答2:
AUDIO_ID
is the unique identifier of the audio file.
_ID
is the identifier of the combination of playlist_id and audio_id.
In this case it's possible to have the same audio in one playlist multiple times. That's why each audiofile to playlist row has an unique identifier _ID
.
It's basically a link table for playlists and audio, and each link has it's own _ID
Like this:
ID AUDIO_ID PLAYLIST_ID
----- ---------- -------------
1 1 1
2 1 1 <----We can have the same combination, so we need an unique identifier.
3 5 1
4 8 2
Source: MediaStore.Audio.Playlists.Members Documentation
来源:https://stackoverflow.com/questions/17648083/what-is-difference-between-id-and-audio-id-column