how to change preferred network type over adb android?

13,145

This is working for my devices:

adb shell sqlite3 /data/data/com.android.providers.settings/databases/settings.db "update global SET value = 1 WHERE name = 'preferred_network_mode'"
adb shell sqlite3 /data/data/com.android.providers.settings/databases/settings.db "select value FROM secure WHERE name = 'preferred_network_mode'"
adb shell settings put global airplane_mode_on 1
adb shell am broadcast -a android.intent.action.AIRPLANE_MODE --ez state true
sleep 5;
adb shell settings put global airplane_mode_on 0
adb shell am broadcast -a android.intent.action.AIRPLANE_MODE --ez state false
Share:
13,145
Sidartha Carvalho
Author by

Sidartha Carvalho

Updated on July 24, 2022

Comments

  • Sidartha Carvalho
    Sidartha Carvalho almost 2 years

    How can I change the preferred network type with ADB?

    Example: set Use only GSM, use only WCDMA, use only LTE or automatic.

  • pooja
    pooja almost 9 years
    Instead of adb reboot you can use airplane mode on/off.
  • Admin
    Admin almost 9 years
    @pooja No, Airplane mode doesn't help in my all the three devices. Only hard/soft-reboot does.
  • pooja
    pooja almost 9 years
    @Arch Its working for my rooted devices. Just check my answer
  • Admin
    Admin almost 9 years
    Could you mention why sleep 5 is needed? And which Android version are your using?
  • Admin
    Admin almost 9 years
    Beside is there a reason sqlite3 ... is used and not settings put global preferred_network_mode 1? Also, what does second command does?
  • Admin
    Admin almost 9 years
    Nope! Not working on CM12 rooted. It changes the value in .db but the changes doesn't take place on the radio level. You can check it in "Phone Info" through *#*#4636#*#* where the preferred_network_type remains the same. What's more, a reboot is kinda reverting things back. Would you mind for the explanation of the commands?
  • pooja
    pooja almost 9 years
    @Arch Its working for lollipop and kitkat. This commands is used to open ur device setting.db and changing preferred_network_mode field with new values.
  • pooja
    pooja almost 9 years
    I did the both reboot and airplane mode .. I don't want to reboot device that's why AP mode used. Sleep used to make some delay. It is changing in device network options.
  • Admin
    Admin almost 9 years
  • Usman
    Usman almost 9 years
    for non-rooted device ??
  • Usman
    Usman almost 9 years
    Error: unable to open database "/data/data/com.android.providers.settings/databases/setting‌​s.db": unable to open database file
  • Kozuch
    Kozuch over 7 years
    This is not working on a rooted Samsung S5 (SM-G901F).
  • Kozuch
    Kozuch over 7 years
    This is not working on a rooted Samsung S5 (SM-G901F).
  • Grayson Henry
    Grayson Henry over 7 years
    @Kozuch which OS are you using? Try stackoverflow.com/questions/37848059/… for the Marshmallow OS
  • Kozuch
    Kozuch over 7 years
    It is Android 5.0.2.
  • Prajwal
    Prajwal almost 6 years
    @Arch why have you not used settings put global preferred_network_mode 1? Why it doesn't work ?(I tried and it's not working)