0

In a dual sim mobile phone, how to get which Preferred SIM for Cellular data.

Can someone help me with that?

Zeeshan Ali
  • 2,211
  • 4
  • 18
  • 25
  • Does this answer your question? [How to check which sim is set as default sim in android programatically](https://stackoverflow.com/questions/32088950/how-to-check-which-sim-is-set-as-default-sim-in-android-programatically) – Shivam Anand Sep 28 '21 at 08:35
  • No, That is not the answer to my question. – Zeeshan Ali Sep 28 '21 at 14:14

1 Answers1

0

I managed to find a solution which works partially. You can use the TelephonyManager to obtain the preferred SIM.

TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);

String activeSIMNetwork = tm.getNetworkOperator();

The catch, sometime, the result is not valid on device reboot.

Meaning, if you change from one SIM to another and check, it will give you the correct preferred SIM set in the phone. But if you reboot the phone and check, it will not give you the correctly displayed preference.

I will post an update if I find another way.

Reference: Sim Management setting Programmatically in android

Hamza Rashid
  • 1,329
  • 15
  • 22