Yatin
Yatin

Reputation: 3120

How to fetch Device Name (NOT Build.MODEL) from Android programatically?

I have been searching for code through which I can fetch Device's name defined by user for his own device . Have gone through various stackoverflow questions , but none seems to work for me ?

Image as seen in below : Will require Thanks Thanks (SM-T211 ) from android code

enter image description here

Upvotes: 1

Views: 2146

Answers (3)

tanmeet
tanmeet

Reputation: 220

You need to get build.prop file of system which is possible either if your device is rooted or if your has system privileges.... heres the code you may follow to get and edit build.prop Check this App in Play Store. build.prop Editor. Since it's open source, and the code is extremely simple, you can use it as a stating point: https://github.com/nathanpc/Build.prop-Editor

Upvotes: 1

Lubomir Babev
Lubomir Babev

Reputation: 1908

Try this :

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

Make sure you add to your manifest:

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

Upvotes: 0

Mande Kira
Mande Kira

Reputation: 190

Try this:

String ownerInfo = Settings.Secure.getString(getContentResolver(),
    "lock_screen_owner_info");

As of Android 4.4.2 the owner info value is moved to lock screen database,/data/system/locksettings.db to which 3rd-party apps have no read/write access. That's, there is no reliable way of reading owner info for later Android versions except for rooted device.

Upvotes: 1

Related Questions