2

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.

  • Some how? That's a bit vague. Where are you getting stuck at exactly? – Huey Aug 21 '15 at 16:03
  • I didn't even know where to start! I actually answered my question. I didn't deserve a down vote! – Amanuel Nega Jan 27 '16 at 9:15
  • @AmanuelNega - SE people are getting worse and worse – Alex S Jun 23 '16 at 8:41
8

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
  1. Check if your carrier is listed in the default list of carriers. [] means optional
# content query --uri content://telephony/carriers [--where "name=''"]
  1. 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>"
  1. Then check the listing again like Step 1

  2. 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>
  1. Try disabling and enabling your internet connection, if no change, restart your phone. if it is still not working, Keep Going

  2. Change permission of settings file

# chmod 666 /data/data/com.android.settings/shared_prefs/com.android.settings_preferences.xml
# exit
$ exit
  1. After you exit adb shell, in your terminal/comand prompt
$ adb pull /data/data/com.android.settings/shared_prefs/com.android.settings_preferences.xml ~/
  1. Add The following line before the last line that says </map>

    <long name="apn_id" value="<id>"/>

  2. 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.

  • Thanks for this. After doining steps 1-4 I can see the APN and it is selected. However, when I reboot, the two records I created are no longer there. – user2233706 Jan 26 '18 at 15:26
  • @user2233706 It's been a while, but one issue I had was wrong mnc and mcc values. Make sure you refer to your provider's numbers. – Amanuel Nega Jan 27 '18 at 3:34
  • I have a phone where the same records persist on reboot, but another phone where it does not. The phones are supposed to be the same. – user2233706 Jan 27 '18 at 15:21
  • @user2233706 I'm sorry, I couldn't help buddy! – Amanuel Nega Jan 28 '18 at 11:31
  • 1
    The file /data/data/com.android.settings/shared_prefs/com.android.settings_preferences.xml does not exist in modern versions of android. Any idea where to apply the change listed in step 8 these days? – Fopedush Nov 14 '18 at 1:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.