The following step solves your problem of changing the default APN, and then returns to the original one.
package com.slk.apnapp; import android.app.Activity; import android.content.ContentResolver; import android.content.ContentValues; import android.database.Cursor; import android.database.SQLException; import android.net.Uri; import android.os.Bundle; import android.telephony.TelephonyManager; import android.util.Log; public class NewAPNActivity extends Activity { public static final Uri APN_TABLE_URI = Uri .parse("content://telephony/carriers"); public static final Uri PREFERRED_APN_URI = Uri .parse("content://telephony/carriers/preferapn"); private static final String TAG = "CHANGE_APN"; public static final String NEW_APN = "NewAPN"; private int getDafaultAPN() { Cursor c = this.getContentResolver().query(PREFERRED_APN_URI, new String[] { "_id", "name" }, null, null, null); int id = -1; if (c != null) { try { if (c.moveToFirst()) id = c.getInt(c.getColumnIndex("_id")); } catch (SQLException e) { Log.d(TAG, e.getMessage()); } c.close(); } return id; } public boolean setDefaultAPN(int id) { boolean res = false; ContentResolver resolver = this.getContentResolver(); ContentValues values = new ContentValues();
source share