How to Change or Restore Android ID on Marshmallow

Did you knew why some of your apps require you to sign-in again after a factory reset (like banking apps) even if you restored the app with data using root access? Well, it’s because everytime you factory reset your device, and it’s set up as a new device with a new unique Android ID.

To avoid re-registering into apps because of your new Android ID, you could restore your old Android ID back. Titanium Backup has a neat function for this. However, with Android 6.0 Marshmallow you may not be able to restore/change your Android ID with Titanium backup or any other tools that worked with Lollipop and previous Android versions.

The reason Titanium Backup won’t work for you is because com.android.providers.settings cannot be backed up by a traditional SQLite database on Android 6.0 Marshmallow. Check out the detailed explanation for this by piit79 from XDA:

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).

Thankfully, piit79 found a way to query/update Settings Storage database using ADB. Below are the commands you need to run to restore/change your Android ID on Marshmallow:

  1. Setup ADB and Fastboot on your PC.
  2. Connect your Android device running on Marshmallow to PC and command window on the PC.
  3. Now issue the following command to get your current Android ID:
    adb shell content query --uri content://settings/secure --where "name=\'android_id\'"

    └ This will show you your current Android ID.

  4. Now issue the following command to change/update the Android ID to the one you want:
    adb shell content update --uri content://settings/secure --bind value:s:<new_android_id> --where "name=\'android_id\'"

    └ Replace text in red with your Android ID.

  5. That’s it. Verify if your Android ID has changed by using the command in 3rd Step.

If the above trick doesn’t work for you, then perhaps you’re better off deleting the current database record and re-insert it with your new Android ID. Use the two commands below for that:

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>

Note: Remember to replace the text in red with your unique Android ID.

All credits for the tip goes to piit79 from XDA, you can check his original post at XDA forums.

Happy Androiding!

Posted by
Shivam Malani

Shivam is our resident designer and web developer who also enjoys writing. He loves to meditate, drive on the freeways and hunt for snipers during his Call Of Duty playtime. Email: [email protected]

17 Comments

  1. There’s a slight formatting difference between your delete method and the one in XDA (note the double hyphen on URI and single hyphen on WHERE):

    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:

    1. Nope. XDA post also has double hyphen.

    2. Your font is correcting it to single hyphen

  2. There’s a slight formatting difference between your delete method and the one in XDA (note the double hyphen on URI and single hyphen on WHERE):

    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:

    1. Nope. XDA post also has double hyphen.

      1. Your font is correcting it to single hyphen

  3. Good to note: if you just want to reset it (to a random android_id), just delete it and restart the device.
    Once the device starts booting up, it will auto-generate a new id.

  4. Good to note: if you just want to reset it (to a random android_id), just delete it and restart the device.
    Once the device starts booting up, it will auto-generate a new id.

  5. […] You might have already seen the method of changing the Android ID using the Query method over ADB. […]

  6. When I tried to use the “adb shell content update …” command, it just silently failed, “adb shell content query …” still showed the old android id.
    But just using the below mentioned “adb shell content insert –uri content://settings/secure –bind name:s:android_id –bind value:s:” [Note, I replace the single hyphen by a double hyphen, else it didn’t work] without deleting the old android id before worked just fine.

    Cyanogenmod 13/Android 6.0.1

  7. When I tried to use the “adb shell content update …” command, it just silently failed, “adb shell content query …” still showed the old android id.
    But just using the below mentioned “adb shell content insert –uri content://settings/secure –bind name:s:android_id –bind value:s:” [Note, I replace the single hyphen by a double hyphen, else it didn’t work] without deleting the old android id before worked just fine.

    Cyanogenmod 13/Android 6.0.1

  8. When I tried to use the “adb shell content update …” command, it just silently failed, “adb shell content query …” still showed the old android id.
    But just using the below mentioned “adb shell content insert –uri content://settings/secure –bind name:s:android_id –bind value:s:” [Note, I replace the single hyphen by a double hyphen, else it didn’t work] without deleting the old android id before worked just fine.

    Cyanogenmod 13/Android 6.0.1

  9. When I tried to use the “adb shell content update …” command, it just silently failed, “adb shell content query …” still showed the old android id.
    But just using the below mentioned “adb shell content insert –uri content://settings/secure –bind name:s:android_id –bind value:s:” [Note, I replace the single hyphen by a double hyphen, else it didn’t work] without deleting the old android id before worked just fine.

    Cyanogenmod 13/Android 6.0.1

  10. How can jar file be install using an SDK into an android app?

  11. How can jar file be install using an SDK into an android app?

  12. How can jar file be install using an SDK into an android app?

  13. How can jar file be install using an SDK into an android app?

Comments are closed.