get and change android device id

## 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/com.android.providers.settings/databases/settings.db “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.

## Reference

1. http://stackoverflow.com/questions/4686263/change-the-device-id-on-an-android-emulator
2. http://stacktips.com/tutorials/android/get-device-id-example-in-android

About 逸飞

后端工程师

发表评论

电子邮件地址不会被公开。 必填项已用*标注