How do you get the user defined "Device Name" in android?

Related searches

I am trying to get the user defined device name that is set in settings. I've tried several options and so far nothing.

If it helps or hurts I am needing it in a BroadcastReceiver


This got me what I was needed...

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

Make sure you add

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

to your manifest

User-defined function, Python: user defined function: In all programming and scripting language, a function is a block of program statements which can be used� You write your own. When you create your own custom function for Excel, it's called a UDF, a User Defined Function. One example of a function that is not included in Excel is a function that returns the fiscal year. There are many ways to calculate the fiscal year from a date with existing functions in Excel.

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

returns Galaxy S5.

String deviceName = android.os.Build.MODEL;
returns SM-G900H.

After some research I found the device_name in /data/data/

so, to get it using shell command

shell@k3g:/ $ settings get system device_name
settings get system device_name
Milky Way

using java

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

POC github project

detailed explanation:

SQL Server User-defined Functions Tutorial with Practical Examples, 'Personalized JavaScript': User-defined functions, objects, and methods. How to take full advantage of JavaScript by moving beyond its built-in commands. Using UI steps to create User-defined Data types. Expand the data base where you want to create data types -> Programmability ->Types. Right click on the User-Defined Data Types and click on New User-Defined Data Type… . A window will pop up to create the type as shown in the below figure.

In summary, there is no single consistent way to retrieve the user-customized device name.

However, there are numerous utilities that you can use that will work on different models and manufacturers:

  1. Settings.System.getString(getContentResolver(), "bluetooth_name"); (docs)
  2. Settings.Secure.getString(getContentResolver(), "bluetooth_name"); (docs)
  3. BluetoothAdapter.getDefaultAdapter().getName(); (docs)
  4. Settings.System.getString(getContentResolver(), "device_name"); (docs)
  5. Settings.Secure.getString(getContentResolver(), "lock_screen_owner_info"); (docs)

1, 2 and 3 appear to be the most reliable on the devices my colleague tested. Here is his full analysis:


Python: user defined function, Users have the ability to define their own functions in CXL scripts by using the CXL User Defined Function Language Element. In creating the functions, the user� User-defined definition: (of a facility on a computer) that can be defined or varied by the user | Meaning, pronunciation, translations and examples

This one worked for me on API 25:

Settings.Secure.getString(getContentResolver(), "bluetooth_name");

Here's how to find it... (just replace the name of your device)

$ adb shell
$ settings list system | grep "<device_name>"
$ settings list secure | grep "<device_name>"

'Personalized JavaScript': User-defined functions, objects, and , Using the "S7-Web2PLC" function you can create user-defined websites in STEP 7 as from version V5.5, which are populated with the content of CPU variables. The web servers provide the websites and are integrated in the CPU modules that support this function.

Following works for me

String deviceName = Settings.Global.getString(.getContentResolver(), Settings.Global.DEVICE_NAME);

User-Defined Functions, If you have the required privilege, you can create and modify project user defined fields. To create or modify a project user defined field. From the Administration Home page, click Project User Defined Fields. To create a new field, click Create User Defined Field. To modify an existing user defined field, click the title of the field.

Right click on the Types folder and select New | User-Defined Data Type.. as shown below: General page of User-Defined Data Type. Below is a example view of the General page for a user defined data type creation. Default schema for user defined data type as 'dbo' Name for user defined data type as 'PhoneNumb'

Congratulation! you successfully created your first user-defined MATLAB function. Once your code is outputting correctly, you can change the values anytime on the command window. Now you can create any function on .m file. Practice! Practice! The more you practice, the more you get comfortable with the software.

  • You can accept your own answer. As it would have been a stretch to guess that you were talking about Bluetooth from your question, I added a tag and mention to the title.
  • In the settings it says nothing about Blue tooth on either of the devices I was working with. I went by trial and error until I found it.
  • Alright, I rolled back my edit. But your solution reveals the problem to be one which has no general solution - on many devices what you are trying to do is simply not possible at all, as there's no means for the user to name the device.
  • please take note. as this answer works, you still have to restart your device if you update your device name on your device settings for you to get the updated name.
  • Since BT is mandatory to ship the phone with Google Apps, we can expect all devices except a few like Amazon Kindle to have…
  • this was returning a null :(
  • This returns what the user named his device in settings: settings get global device_name and in java Settings.Global.getString(getContentResolver(), "device_name");
  • That shell command returns "null" on Android P (Pixel) despite having set the value in the Settings section of the phone.
  • The Settings.System method now returns "null" as well.
  • thanks for providing this answer interpreting the question as being about the device's user-assigned name, not the device's model name. as others have mentioned, none of the methods here seem to be working with my kindle (android 5.1.1). They return variously null, Fire, or KFDOWI. hm. android docs say that device_name was added in API level 25, which apparently means Fire OS 6, so i guess this makes sense. sort of. why is settings get global device_name returning anything at all then ?
  • Unfortunately, none of these methods work on Pixel 2 XL emulator (api 28). They all return null!