Android request ContactsContract in Kotlin

I am having trouble trying to request ContactsContract in an android application written in Kotlin. Android studio gives errors from unresolved links like ContactsContract.Contacts._ID. Does anyone know the correct way to query them in Kotlin?

+3


source to share


1 answer


This is an open bug in Kotlin. Please refer to: https://youtrack.jetbrains.com/issue/KT-3180 .

Now you can use Java to access fields like this workaround:



public class ContactsSupport {
    public static interface BaseColumns {
        public static final String _ID = ContactsContract.RawContacts._ID;
        public static final String _COUNT = ContactsContract.RawContacts._COUNT;
    }
}

      

So you can write ContactsSupport.BaseColumns._ID

in Kotlin.

+4


source







All Articles