22

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?

Community
  • 1
  • 1
Janusz
  • 187,060
  • 113
  • 301
  • 369

2 Answers2

17
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'"
Habbah
  • 171
  • 1
  • 3
8

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.

Community
  • 1
  • 1
Christopher Orr
  • 110,418
  • 27
  • 198
  • 193
  • Thanks I tried the code in the question and it didn't work but now I realized it was an error on my part and got it working. – Janusz Jul 28 '10 at 16:05
  • I wanted to corroborate the part about the ID not always being present. When I tested on emulators we had issues with this. I don't remember if the ID was never present or was just occasionally missing, but I do remember that it was not always there on emulators – Hamy Jul 29 '10 at 05:58