Search code examples
sqliteandroid-contentresolver

does a content resolver change it's primary key


I'm trying to setup a virtual interface for the database for all the music files using a content resolver. But, I have a small issue which I realized it could happen after developing a lot.

I was using MediaStore.Audio.Media._ID as the primary key which linked to multiple sqlite databases , now I wonder if the system could rearrange the keys (even when the data isn't modified/renamed/deleted) at some point.

Say for example x/y/z/a.mp3 had this MediaStore.Audio.Media._ID= 1 but after some time can the file have some other value assigned to this _ID?


Solution

  • _ID is the unique id for the row and will not change unless you force it to.

    https://developer.android.com/reference/kotlin/android/provider/BaseColumns#_ID:kotlin.String