How do I add an APN via ADB? For hardware reasons (My menu key doesn't work) I can not add an APN via settings. I read here about using sqlite and here about using code. But I need a more convenient way to do it. I need to do it using adb.
You Should


1. Be Root
2. Know APN fileds such as MCC and MNC of your service provider [e.g EthioTelecom is mcc=636 mnc=01]


Steps


Open adb shell    



    $ adb shell
    $ su



Check if your carrier is listed in the default list of carriers. [] means optional



# content query --uri content://telephony/carriers [--where "name=''"]



If your carrier is not listed, you have to add it to the list, Add other fields as required. NOTE the following is for Internet, for MMS, change the fileds to what is required



    # content insert --uri content://telephony/carriers --bind name:s:"&lt;Carrier Name&gt;" --bind numeric:s:"&lt;mcc&gt;&lt;mnc&gt;" --bind type:s:"default,sulp" --bind mcc:i:&ltmcc&gt; --bind mnc:s:&lt;mnc&gt;--bind apn:s:&lt;apn&gt;  --bind user:s:"&lt;User&gt; --bind password:s:"&lt;Password&gt;"



Then check the listing again like Step 1
Note the _id, replace insert by update if this is not the first time you are setting the prefered apn



# content insert --uri content://telephony/carriers/preferapn --bind apn_id:i:&lt;_id&gt;



Try disabling and enabling your internet connection, if no change, restart your phone. if it is still not working, Keep Going
Change permission of settings file



# chmod 666 /data/data/com.android.settings/shared_prefs/com.android.settings_preferences.xml
# exit
$ exit



After you exit adb shell, in your terminal/comand prompt



$ adb pull /data/data/com.android.settings/shared_prefs/com.android.settings_preferences.xml ~/



Add The following line before the last line that says &lt;/map&gt;

&lt;long name="apn_id" value="&lt;id&gt;"/&gt;
then save it and run



$ adb push ~/com.android.settings_preferences.xml /data/data/com.android.settings/shared_prefs/com.android.settings_preferences.xml


Hopefully, You should now see your apn in the access points screen in settings, and it should also work.