'How to get call logs of only one sim if you have 2 sim in a phone?

I want to develop an app which can access the call logs of the user, but only access the log of a particular sim if the user have 2 sim in their phone.



Solution 1:[1]

From here:

You can use "sub_id" constant value to get information about sim card.

Full path to this value CallLog.Calls.SUB_ID = "sub_id", but is not available for public, so just hardcode in API before 21. For >=21 you can use PHONE_ACCOUNT_COMPONENT_NAME.

PHONE_ACCOUNT_COMPONENT_NAME is officially documented here, along with the rest of the documentation on accessing call logs.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 atrocia6