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.
- 1. Be Root
- 2. Know APN fileds such as MCC and MNC of your service provider [e.g EthioTelecom is mcc=636 mnc=01]
- 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:"<Carrier Name>" --bind numeric:s:"<mcc><mnc>" --bind type:s:"default,sulp" --bind mcc:i:<mcc> --bind mnc:s:<mnc>--bind apn:s:<apn> --bind user:s:"<User> --bind password:s:"<Password>"
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:<_id>
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
<long name="apn_id" value="<id>"/>
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.