Appium to get Android device system locale properties

By running adb shell getprop command, you can get device properties, including device system language/country or locale information depends on the version of the Android OS.

You can do the same thing(running adb shell command) from within Appium test script, which may help you in case you cannot make a direct adb connection from your test script to the target device.

adb shell getprop

By using adb shell command, you can get device system properties, like below,

$ adb shell getprop

[af.fast_track_multiplier]: [1]
[]: [true]
[persist.sys.locale]: [en-US]                 <----- system locale info
[]: [6.0]
[]: [23]
[ro.product.locale]: [ja-JP]                  <----- product locale info (product static)
[ro.product.manufacturer]: [LGE]
[ro.product.model]: [LGV32]
[]: [p1_kddi_jp]
[ro.product.model]: [LGV32]

$ adb shell getprop ro.product.locale

From Appium

Appium itself does not provide an API to do the same thing, but it instead, provides more generic API, `execute`. You can run mobile specific commands by using it.

You can run adb shell commands, as shown below,

const wdio = require("webdriverio");

const opts = {
    port: 4723,
    desiredCapabilities: {
        platformName: "Android",
        platformVersion: "9",
        deviceName: "PH-1",
        app: "/path/to/apk/app-debug.apk",
        automationName: "UiAutomator2"

const client = wdio.remote(opts);

client.init().execute('mobile: shell',  {command: 'getprop persist.sys.locale'}).then( res => console.log(res.value));


  • The appium server needs to be run with `–relaxed-security` option set.
    This means that if you have no control over appium server(e.g. if you are using a public remote device provider), the above method may not work, so you should check if this works on your setup and device provider.
  • The property name, may be different based on the Android OS version(s).
    • Older versions of OS(4.x?)
      • persist.sys.language
    • Newer versions of OS(5.0+?)
      • persis.sys.locale

Using adb wrapper

You can run adb command(s) by using an adb wrapper library, like below.

const appuimADB = require('appium-adb')
const  {ADB} = appuimADB
let adb = new ADB();'getprop persist.sys.locale').then(res => (console.log(res)));

*) Please note that this works only in the setup where adb commands directly works, so this may not work on a device provided by a public remote device farm.

Setting locale from adb

You basically cannot do it, unless you do it against rooted device or avd.

Per the SO answer, the following adb command should do the job.

adb shell
root@generic:/ # getprop persist.sys.language
getprop persist.sys.language
root@generic:/ # setprop persist.sys.language fr
setprop persist.sys.language fr
root@generic:/ # setprop CA
setprop CA
root@generic:/ # stop
root@generic:/ # start
root@generic:/ # sleep 5
sleep 5
root@generic:/ # getprop |grep lang
getprop |grep lang
[persist.sys.language]: [fr]
root@generic:/ # getprop |grep country
getprop |grep country
[]: [CA]
root@generic:/ #

Setting from Application

It’s not using adb, but Android app with an appropriate permission can change the language/locale setting of the device(until Android 5.0).

From Android 4.2 and before 5.0, you also need to give your app the following permission.

$ adb shell pm grant com.yourapp.packagename android.permission.CHANGE_CONFIGURATION


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s