Read APNs in Android 4.2?

If you want to Read APN for Android 4.2 and more they are a change to do. I tested and it’s work.

In Android 4.1 and below use this :

Cursor c = getContentResolver().query(Uri.withAppendedPath(Telephony.Carriers.CONTENT_URI, "current"), null, null, null, null);

And for Android 4.2 and above use this code :

private static final String[] APN_PROJECTION = {
     Telephony.Carriers.TYPE,            // 0
     Telephony.Carriers.MMSC,            // 1
     Telephony.Carriers.MMSPROXY,        // 2
     Telephony.Carriers.MMSPORT          // 3
 };

And this line :

final Cursor apnCursor =SqliteWrapper.query(context, this.context.getContentResolver(), Uri.withAppendedPath(Carriers.CONTENT_URI, "current"), APN_PROJECTION, null, null, null);

The SQLiteWrapperClass is hidden (found this class in internet)

import android.database.sqlite.SqliteWrapper;

My English is not quite good, sorry for this.

Leave a Comment