The APN for Android

Source: Internet
Author: User

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/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.