I wanted to get the device name specified in Settings->About->DeviceName but I did not see any method in Android SDK that you can call to obtain this information. why ? Because this is only specific to Samsung Android devices, rather than a part of Android itself.
So, how to get the device name ??
1. i tried
BluetoothAdapter myDevice = BluetoothAdapter.getDefaultAdapter();
String deviceName = myDevice.getName();
This returns Galexy S5, useless
2. android.os.Build.MODEL;
returns SM-G900H
3. Had to go deep. then i remembered android has a system values database. which is located at
So I pulled it from my Samsung and took a look
/data/data/com.android.providers.settings/databases/settings.db
So, how to get this using shell
shell@k3g:/ $ settings get system device_name
settings get system device_name
Milky Way
Using java
String deviceName = Settings.System.getString(getContentResolver(), "device_name");
Github project
https://github.com/kakopappa/getdevcicename/blob/master/README.md