The APN full name is access point name, the Chinese is the AP, which is a parameter that must be configured to access the Internet via the phone, which determines which access method the phone accesses to the network.
The Android system keeps all the APN in the database, the absolute path of the database:/data/data/com.android.providers.telephony/databases/telephony.db.
Use the ADB command to export the database to view:
ADB pull/data/data/com.android.providers.telephony/databases/telephony.db e:/
Get all of the APN's URI addresses as "content://telephony/carriers".
Gets the URI address currently used by APN as "CONTENT://TELEPHONY/CARRIERS/PREFERAPN".
Android current APN is saved in an XML file, absolute path:/data/data/com.android.providers.telephony/shared_prefs/preferred-apn.xml.
Use the command export to view:
ADB pull/data/data/com.android.providers.telephony/shared_prefs/preferred-apn.xml e:/
The contents are as follows:
<? ?> <map> <name = "apn_id" value = "2" /> </ Map >
Instance code:
//Get all APNURI URI= Uri.parse ("Content://telephony/carriers"); Cursor CR= Getcontentresolver (). Query (URI,NULL,NULL,NULL,NULL); //Traverse all APN while(cr!=NULL&&Cr.movetonext ()) { //APN IDString ID= Cr.getstring (Cr.getcolumnindex ("_id")); //APN nameString APN= Cr.getstring (Cr.getcolumnindex ("APN")); 。。。。 } //Get current APNURI URI= Uri.parse ("CONTENT://TELEPHONY/CARRIERS/PREFERAPN"); Cursor CR= Getcontentresolver (). Query (URI,NULL,NULL,NULL,NULL); //Modify Current APNURI URI= Uri.parse ("CONTENT://TELEPHONY/CARRIERS/PREFERAPN"); Contentresolver Resolver=Getcontentresolver (); Contentvalues Values=Newcontentvalues (); Values.put ("APN_ID", id); Resolver.update (URI, values,NULL,NULL);
This article transferred from: Http://blog.163.com/[email protected]/blog/static/6715605020114234013308/