Take the 2-minute tour ×

I am looking for the easiest way to get a unique android device identifier from both the Android adb and the Android ADK itself.

For example, when i use the adb 'devices' command, the serial number of my connected device is outputted to the screen. I have yet to identify a method in the Android sdk to get me the same serial number.

I don't care what unique identifier is used, just something that can be easily retrieved from both the adb and android sdk. Rooting a device will not be an option.

share|improve this question
Could you track installations instead of devices? –  ridecar2 Apr 25 '12 at 15:17
found look into following answer. stackoverflow.com/a/23564966/884052 –  Ajeet Khadke May 9 at 12:49

5 Answers 5

You would probably want to use ANDROID_ID.

This is how you can query its value via adb shell:

settings get secure android_id

Or by querying the settings content provider:

content query --uri content://settings/secure --projection name:value --where "name='android_id'"
share|improve this answer
Content doesn't seem to be a found by the shell? –  jeffamaphone Jan 15 '13 at 19:17
Just escape the ['] chars in the end of the query to run it smoothly. –  Martynas Jurkus Aug 4 '13 at 11:51

Android stores all the device related info in one or the other sqlite DB. These databases can be found in /data/data/ folder. To read these databases from adb you will need root permissions.

The android id is available in /data/data/com.android.providers.settings/databases/settings.db

So for adb use this command.

adb shell sqlite3 /data/data/com.android.providers.settings/databases/settings.db "select value from secure where name = 'android_id'"

**you must be running adb as root in adb

share|improve this answer
Thankyou, this works for me. –  shshank Oct 17 '13 at 14:23
Thank you! It helps me –  exbluesbreaker Aug 4 at 9:29

Try ANDROID_ID. As documentation says "[it] is randomly generated on first boot and should remain constant for the lifetime of the device".

share|improve this answer
Do have any idea of how this can be accessed from adb? –  user163757 Mar 30 '11 at 14:19
As far as I know most reliable way will be to create an application that copies it (ANDORID_ID) to database. Than you can access this database trough adb (use sqlite3 command from shell). –  Andrzej Duś Mar 30 '11 at 14:57
I haven't tested it myself but you may also find ANDORID_ID already stored in this places: - /data/data/com.android.providers.settings/databases/settings.db - table secure - /data/data/com.google.android.googleapps/databases/gls.db - table meta –  Andrzej Duś Mar 30 '11 at 15:05

It's already been shown that ANDROID_ID is not fullproof. There was an issue with all Droid 2's having the same ANDROID_ID (i'm not sure if this has changed). Even if it is randomly generated, this wouldn't necassarily make it unique since two devices could (by unlucky chance) get the same id...

I too would like to know how you get the android adb id.

share|improve this answer

you should probably use IMEI:

    TelephonyManager m = (TelephonyManager) context
    String imei = m != null ? m.getDeviceId() : null;
share|improve this answer
IMEI may not be a good proxy for a unique identifier since you can't guarantee that every device your app runs on will have a cell radio. Given that you can specify a <uses-feature> for android.hardware.telephony, I wouldn't recommend assuming the presence of telephony hardware. On the other hand, if you're happy restricting your app to only those devices with telephony hardware, then this should be useable. –  RivieraKid Mar 30 '11 at 13:29

Your Answer


