0

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)

akhy
  • 5,760
  • 6
  • 39
  • 60

2 Answers2

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

Timmetje
  • 7,641
  • 18
  • 36
  • so, audio files in a playlist has sequential _ID from 0 to playlist size - 1? – akhy Jul 15 '13 at 06:44
  • FYI, what I'm exactly doing is trying to get absolute reference to audio files that can be exists in multiple playlists and store them in flat file. Should I use AUDIO_ID or _ID? – akhy Jul 15 '13 at 06:46
  • 1
    It's basically a link table for playlists and audio, and each link has it's own _ID – Timmetje Jul 15 '13 at 06:47
  • 1
    The `audio_ID` is absolute reference to the AUDIO. Which can exists in multiple playlists. The `ID` will refer you to an unique combination of audio within a playlist. – Timmetje Jul 15 '13 at 06:48
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

Community
  • 1
  • 1
Chintan Rathod
  • 25,864
  • 13
  • 83
  • 93
  • Ah, got it. So _ID is analogous to row number in SQL query result, and AUDIO_ID is more like primary key for each audio. Am I right? – akhy Jul 15 '13 at 06:49
  • 1
    Yes. _ID is primary key for each row of audio entry. But AUDIO_ID is unique id given to particular file. – Chintan Rathod Jul 15 '13 at 06:50