hopia
hopia

Reputation: 5006

How to get Samsung Android Device Name programmatically?

Other similar questions in SO are answered by retrieving the Build.MODEL name.

But what I would really like is to get the customizable Device name on Samsung Devices. I know it is customizable because on my Galaxy Note, I can change it from the settings->About device. For example, below, I would like to retrieve the "Milky Way" string.

enter image description here

Upvotes: 5

Views: 5420

Answers (3)

Triệu Đô La
Triệu Đô La

Reputation: 2481

Settings.Global.getString(context.getContentResolver(), "device_name") It working for me.

Upvotes: 0

kakopappa
kakopappa

Reputation: 5085

I tried

BluetoothAdapter myDevice = BluetoothAdapter.getDefaultAdapter();
String deviceName = myDevice.getName();

still returns the SM-G900H.

After some research I found the device_name in /data/data/com.android.providers.settings/da‌​tabases/settings‌​.db

I manage to get it using following shell command

settings get system device_name

Code:

String deviceName = Settings.System.getString(getContentResolver(), "device_name");

Upvotes: 1

Emanuel
Emanuel

Reputation: 8106

There is no common way getting this, since it's not a "android-feature" more likely a Samsung Feature afaik.

Try getting it with this, which worked on my galaxy s3, s4 and s5

BluetoothAdapter myDevice = BluetoothAdapter.getDefaultAdapter();
String deviceName = myDevice.getName();

Do not forget to add the bluetooth permissions.

<uses-permission android:name="android.permission.BLUETOOTH"/>

Upvotes: 4

Related Questions