MSISDN : Is it a SIM Card Data? Why all The Provided Function (from Blackberry and Android) to fetch MSISDN not reliable?

The question:

I have several question about MSISDNs. I understand:

  1. MSISDN is the basically the phone number
  2. It is not IMSI

What i need to know further are:

  1. Is MSISDN number burnt (stored) in SIM Card? If it is yes, are all providers make sure that there is MSISDN information in SIM Card? If it is no, to be clarified, None of programming code can fetch the MSISDN number?

  2. Some people suggest to fetch MSISDN as below code. But both the code return null if “My Phone Number” is not set in device. On the other way around, it will return the “My Phone Number” if it is set.
    Thus, the question is: “My Phone Number” equals to MSISDN?

    TelephonyManager.getLine1Number(); –> for Android

    Phone.getDevicePhoneNumber(true); –> for Blackberry

  3. As code above, the return String data is fetched from the device itself or from the SIM Card?

The Solutions:

Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.

Method 1

I have some insight into the matter for you.

  1. The MSISDN can be stored on the SIM card, however most network providers (all providers in South Africa) do not store the MSISDN on the SIM card. There are several reasons for this, the most notable being:
    • Dynamic MSISDN allocation: Prepaid SIMs are sometime allocated an MSISDN when they are first used. This means that the network has a pool of available MSISDNs and allocate them whenever a new prepaid SIM comes online. This means that when the SIMs are shipped they do not have an MSISDN yet, which means you can’t store an MSISDN prior to shipping the SIMs. Some networks ‘expire’ MSISDN allocations after a period of inactivity, especially when their available numbers are running low, and return these numbers to the available pool.
    • Mobile Number Portability: Some countries allow mobile subscribers to keep their MSISDN but change networks. This means that the MSISDN will be moved from a SIM that is for 1 network to a SIM that is for another network.

So the user often ends up with the MSISDN entry on the SIM being blank. The user can still store the MSISDN on the SIM themselves, but this also allows them to store any arbitrary number, and it is not guaranteed to be set or to even be the subscribers actual phone number.

   2. Those calls you asked about fetch the number that is stored in the SIM card. If the number is not set you won’t get it, and if the user has the wrong number set then you will have the incorrect details.

   3. Correct, this string is fetched from the SIM itself.

The only semi-reliable way I have for detecting MSISDN is via WAP/WEB when the Mobile Operator includes the MSISDN in the headers (you can do some webview trickery to see what headers are coming through) – however you only see these if the network supports it and if the user is on Mobile Data – i.e. It won’t work if the user is on WiFi.

The other mechanism I can think of (the only guaranteed mechanism I can think of) is via a USSD session, as you always get the correct MSISDN from the operator, but I haven’t found a way of programatically opening a USSD session and reading the response (in Android at least). I have a USSD service whose only output is the MSISDN but unfortunately this hasn’t proven usable to me yet.

Method 2

Since nobody replied in the last hour since you posted your question, here is what I know (although I am not an expert in this area, just have some experience):

  1. MSISDN is the phone number; the number people can call you on.
  2. It cannot be “burnt” into the sim card as you can change sim card (upgrade or changing to other operator) and keep your phone number = MSISDN. I think there is a mapping table at the operators that covert from sim card ID to MSISDN and back when call/data transfer is made. The MSISDN might be stored on the card.

Method 3

You should take into account that MSISDN has BIGINT type.
Therefore outputting it make type transformation in advance,
like this

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Comment