Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to obtain the android_id of a device? [duplicate]

Tags:

Possible Duplicate:
Is there a unique Android device ID?

In the licensing documentation the android developers mention an easy way to more or less securely identify an android device. They are using android.Settings.Secure.ANDROID_ID.

They say they query the system settings for this. But they don't explain this any further.

How do I obtain the android_id and do I need special permissions for doing so?

like image 680
Janusz Avatar asked Jul 28 '10 14:07

Janusz


People also ask

How do I find the unique ID of my Android phone?

* getDeviceId() returns the unique device ID. * For example,the IMEI for GSM and the MEID or ESN for CDMA phones. * getSubscriberId() returns the unique subscriber ID, * For example, the IMSI for a GSM phone.

How do I find my Android Secure ID?

Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml. In the above code, we have taken text view to show device id.

What is the best identifier to use to uniquely identify a device?

ANDROID_ID is the preferred device identifier. ANDROID_ID is perfectly reliable on versions of Android <=2.1 or >=2.3.

What is ANDROID_ID?

ANDROID_ID. On Android 8.0 (API level 26) and higher versions of the platform, a 64-bit number (expressed as a hexadecimal string), unique to each combination of app-signing key, user, and device.


2 Answers

adb shell sqlite3 /data/data/com.android.providers.settings/databases/settings.db "SELECT value FROM secure WHERE name='android_id'" 

The android id is changeable with a rooted phone... Insert a android id with:

adb shell sqlite3 /data/data/com.android.providers.settings/databases/settings.db "UPDATE secure SET value='IDHERE' WHERE name='android_id'" 
like image 155
Habbah Avatar answered Sep 24 '22 08:09

Habbah


It's all in the Javadoc, as linked to by this question you edited 30 minutes before this one! :)
Is there a unique Android device ID?

The "Secure" part just means that apps can't write to it, only read. I seem to recall that this device ID isn't always present; it's populated by the Market as required, perhaps.

like image 20
Christopher Orr Avatar answered Sep 22 '22 08:09

Christopher Orr