get and change android device id

Author: yifei / Created: May 29, 2017, 10:48 p.m. / Modified: May 29, 2017, 10:51 p.m. / Edit

get device id

String id = Secure.getString(getContentResolver(), Secure.ANDROID_ID);

set device id

As far as Settings.Secure.ANDROID_ID goes, this should do the trick:

adb shell sqlite3 /data/data/ "UPDATE secure SET value='newid' WHERE name='android_id'"

Where newid is usually the 16 hex digit code (i.e. don't append "Android_" to it). I only tried this on the emulator. I imagine a real phone would need to be rooted first.



有任何问题可以发邮件到 kongyifei (at) 讨论