You need to set the MCC )(Mobile Country Code) and MNC (Mobile Network
Code) values too in your code to set and display the APN's on Android UI.
Try the following code and see what happens:
>
> *private static* *final* Uri *PREFERRED_CONTENT_URI* = Uri.*parse*(
> "content://telephony/carriers/preferapn");
>
>
>
> // getCurrentPreferredAPN is an internal function to retrieve the "_id" of
> the current APN.
> String strCurrent = getCurrentPreferredAPN();
>
> ContentValues values = *new* ContentValues();
>
> Uri ret;
>
String MCC = null, MNC = null;
TelephonyManager tel = (TelephonyManager)
getSystemService(this.TELEPHONY_SERVICE);
String networkOperator = tel.getNetworkOperator();
if (networkOperator != null) {
MCC = networkOperator.substring(0, 3);
MNC = networkOperator.substring(3);
}
>
>
// create the dummy ID
>
> values.put(*SZ_NAME*, *"blah"*);
> values.put(*SZ_APN*, *"blah"*);
>
> values.put(*SZ_TYPE*
> , *"blah"*);
>
> values.put("current", "1");
>
> values.put("mcc", MCC);
> values.put("mnc", MNC);
>
>
> // 'delete' the current entry.
> nUpdated = getContentResolver().delete(PREFERRED_CONTENT_URI, "_id=?",
> new String[] { strCurrent };
>
> // 'insert' a new entry.
> ret = getContentResolver().insert(PREFERRED_*CONTENT_URI*, values);
> *if*(*null* == ret)
>
> {
>
> Log.*i*("Add Dummy APN", "Failed");
>
> *return*;
>
> }
>
>
>
> The call ==> "insert"* ==>* is always returning null for me.
>
>
>
> What is the right way of doing this?
>
>
>
>
>
> **
>
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en