Mero
Mero

Reputation: 309

Querying Androids ContactsContract in Kotlin

I am having a bit of a trouble trying to query ContactsContract in an android app written in Kotlin. Android studio gives errors from unresolved references for example from ContactsContract.Contacts._ID. Does anyone know the right way to query these in Kotlin?

Upvotes: 3

Views: 605

Answers (1)

yanex
yanex

Reputation: 1109

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

For now you could use Java to access such fields as a 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.

Upvotes: 4

Related Questions