FORUMS
Remove All Ads from XDA

How to Restore/Change Android ID in Android 6.0 Marshmallow

324 posts
Thanks Meter: 305
 
By piit79, Senior Member on 6th October 2015, 10:00 PM
Post Reply Email Thread
I haven't found this posted anywhere so figured it might be useful to others as well.

When you reinstall Android it is set up as a new device with a new unique Android ID. This ID is often used by apps to identify the device - for example all my internet banking apps use it to register the device with the service. To avoid having to re-register after reinstall the ID can be changed to what it was previously.

The Android ID backup/restore function is included in Titanium Backup. However, the Settings Storage (com.android.providers.settings) doesn't seem to be backed by a traditional SQLite database in Android 6.0 Marshmallow - /data/data/com.android.providers.settings/databases/settings.db is empty (0 bytes) on my device. Therefore the Android ID cannot be restored/changed by the usual tools (including Titanium Backup).

I have found a way to query/update the settings database via adb though as follows:
Get current Android ID:
Code:
adb shell content query --uri content://settings/secure --where "name=\'android_id\'"
Normally, you would update the value as follows:
Code:
adb shell content update --uri content://settings/secure --bind value:s:<new_android_id> --where "name=\'android_id\'"
However, this wasn't working for me - I kept getting the same ID when querying after update. So, I tried removing the current record and re-inserting it with the new ID:
Code:
adb shell content delete --uri content://settings/secure --where "name=\'android_id\'"
adb shell content insert --uri content://settings/secure --bind name:s:android_id --bind value:s:<new_android_id>
Which worked just fine
The Following 44 Users Say Thank You to piit79 For This Useful Post: [ View ] Gift piit79 Ad-Free
 
 
6th October 2015, 11:36 PM |#2  
Member
Vermont
Thanks Meter: 30
 
More
Any idea if this works going from CM to Stock or the reverse? Or does it only work stock to stock?

I ask because my two factor auth token for work is on my CM, but if I restore it on stock using Titanium Backup, it works oddly. I wonder if changing the ID would make it work better on stock
7th October 2015, 05:49 AM |#3  
Member
Franklin, Ma
Thanks Meter: 16
 
More
Sweet. Any idea how to do this to get the device ID for exchange in gmail?
7th October 2015, 12:40 PM |#4  
guinnes.s's Avatar
Senior Member
Thanks Meter: 28
 
More
So were the SETTINGS.DB file gone?
9th October 2015, 11:01 AM |#5  
mavaddat's Avatar
Junior Member
Flag Vancouver
Thanks Meter: 4
 
Donate to Me
More
For Windows, exclude escape characters
Simply perfect. I was worried when Titanium Backup couldn't restore old ID, but this worked like a beauty.
The only hitch was that the cmd.exe doesn't need escape characters for apostrophes.
So the code for me was just
Code:
adb shell content delete --uri content://settings/secure --where "name='android_id'"
adb.exe shell content insert --uri content://settings/secure --bind name:s:android_id --bind value:s:<newID>
The Following 4 Users Say Thank You to mavaddat For This Useful Post: [ View ] Gift mavaddat Ad-Free
9th October 2015, 07:37 PM |#6  
Senior Member
Thanks Meter: 23
 
More
edit: installing adbwireless and using that solved the problem. not sure why adb from my computer won't work though.

I have the latest SDK installed, have root, and have allowd adb shell root privileges and everytime i run a command I get:

tmp-mksh: adb: not found

Can anyone help me out? I'm using a Nexus 6.

edit: seems like no matter what command i type i get adb : not found. I get a response from the command adb devices when I don't have a shell open. running the abobe commands outside of a shell returns an error, and when i go into a shell no commands work. I always get the adb: not found response.
14th October 2015, 01:17 PM |#7  
Member
Thanks Meter: 10
 
More
exactly what I just needed for my nexus 5, worked flawless... thanks a lot!
The Following User Says Thank You to drmason For This Useful Post: [ View ] Gift drmason Ad-Free
15th October 2015, 10:17 AM |#8  
mavaddat's Avatar
Junior Member
Flag Vancouver
Thanks Meter: 4
 
Donate to Me
More
Quote:
Originally Posted by nyreyn

edit: installing adbwireless and using that solved the problem. not sure why adb from my computer won't work though.

I have the latest SDK installed, have root, and have allowd adb shell root privileges and everytime i run a command I get:

tmp-mksh: adb: not found

Can anyone help me out? I'm using a Nexus 6.

edit: seems like no matter what command i type i get adb : not found. I get a response from the command adb devices when I don't have a shell open. running the abobe commands outside of a shell returns an error, and when i go into a shell no commands work. I always get the adb: not found response.

Of course! This is a simple problem arising from the absence of the adb.exe executable from the system path being read by your shell or terminal program. You can either add your adb.exe to your system path or else navigate to the platform-tools directory and use the adb.exe from there:
  1. Verify that adb.exe resides in %LOCALAPPDATA%\Android\sdk\platform-tools\
  2. Set the path and restart the cmd or PowerShell and then try again.
16th October 2015, 02:09 AM |#9  
Senior Member
Thanks Meter: 30
 
More
I tried doing this, but my adb shell doesn't seem to have content in its sbin.
Nevermind.. it works now.
17th October 2015, 02:26 AM |#10  
Junior Member
Thanks Meter: 2
 
More
Quote:
Originally Posted by piit79

I haven't found this posted anywhere so figured it might be useful to others as well.

When you reinstall Android it is set up as a new device with a new unique Android ID. This ID is often used by apps to identify the device - for example all my internet banking apps use it to register the device with the service. To avoid having to re-register after reinstall the ID can be changed to what it was previously.

The Android ID backup/restore function is included in Titanium Backup. However, the Settings Storage (com.android.providers.settings) doesn't seem to be backed by a traditional SQLite database in Android 6.0 Marshmallow - /data/data/com.android.providers.settings/databases/settings.db is empty (0 bytes) on my device. Therefore the Android ID cannot be restored/changed by the usual tools (including Titanium Backup).

I have found a way to query/update the settings database via adb though as follows:
Get current Android ID:

Code:
adb shell content query --uri content://settings/secure --where "name=\'android_id\'"
Normally, you would update the value as follows:
Code:
adb shell content update --uri content://settings/secure --bind value:s:<new_android_id> --where "name=\'android_id\'"
However, this wasn't working for me - I kept getting the same ID when querying after update. So, I tried removing the current record and re-inserting it with the new ID:
Code:
adb shell content delete --uri content://settings/secure --where "name=\'android_id\'"
adb shell content insert --uri content://settings/secure --bind name:s:android_id --bind value:s:<new_android_id>
Which worked just fine

Thanks! Thanks! Thanks! Thanks! Thanks! Thanks! Thanks!
The Following 2 Users Say Thank You to destbr For This Useful Post: [ View ] Gift destbr Ad-Free
17th October 2015, 08:18 AM |#11  
Senior Member
Thanks Meter: 88
 
Donate to Me
More
Sign
Hi,

another way is :


to read Android ID:
Code:
adb shell settings get secure android_id
To write Android ID:
Code:
adb shell settings put secure android_id <new_android_id>
Tested on Android 6.0 Marshmallow.
The Following 21 Users Say Thank You to Crios For This Useful Post: [ View ] Gift Crios Ad-Free
Post Reply Subscribe to Thread

Tags
android id, marshmallow

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes