1

It seems that daily, I see some question along the lines of "issue X is causing my phone to be inoperable, and debugging is off. How do I enable ADB to get my data?"

I understand that this issue can be fairly common, so i thought i would put out a way to re-enable adb - using nothing but root privileges and a custom recovery.

This can also be used when, say, my developer options cannot be opened for some reason.

I know this will not eliminate this kind of question, but it can help with some of them.

See answer for method. Had to upload this as a "answer your own question" thing

3

You are going to need the following:

  • Root (YAY!)
  • A custom recovery, specifically TWRP (Untried on a different recovery, anyone let me know if it works on any other)
  • A PC/device with a way of editing SQLite .db files
  • An SD card

Method

  1. If you have not already, boot into Recovery mode. Ensure you mount 'data' and 'External SD card'

  2. Smack that 'advanced' button, open a terminal shell, and type su (then smack enter)

  3. Run this command:

    cp /data/data/com.android.providers.settings/databases/settings.db /path_to/external_sd/
    

    (Thanks to the guys at SO for providing that.) If you don't have cp or busybox installed, you could use cat instead:

    cat /data/data/com.android.providers.settings/databases/settings.db > /path_to/external_sd/settings.db
    
  4. Power off, and remove your SD. Stick it in the device with the .db editor.

  5. Load the file

  6. Go to the 'secure' table, and find the line adb_enabled. In my case, this was line 59. The value should be 0 if ADB is disabled. Change it to 1, and save.

  7. With the modified file in tow, poke the SD card back into your device, and boot back into recovery. Again, make sure 'data' and 'External SD card' are mounted.

  8. Reverse the copy you did above:

    cp /path_to/external_sd/settings.db /data/data/com.android.providers.settings/databases/
    

    or

    cat /path_to/external_sd/settings.db > /data/data/com.android.providers.settings/databases/settings.db
    
  9. Done! Now, to get authorization, you will need to use Firelord's post and follow his master plan there :) Alternatively, you can use the accepted answer to This post on Stack Overflow. Those guys are helpful, eh?

Note: If you can boot your device, you can download SQLite editor and cut out the need for another device, an SD card, and, well, anything else. It is paid, however! Ifmyou want to save money, you can use the free a SQLite Manager instead.

  • I would skip the secondary device and just edit it on the phone with something like SQLite Editor. And is it necessary to have the OS not running when making this change? I.e., will it overwrite your change if running live? If not, then you could skip Recovery and the copying, and just edit it directly. – Matthew Read Aug 9 '16 at 20:39
  • @MatthewRead The issue is that since this method is mainly for those stuck in recovery, They won't really be able to open it. If they are on a usable OS, then Yes, you are correct. I'll edit that in now. – Dan Brown Aug 9 '16 at 20:45
  • Ah, good point. Yes, this would definitely help someone stuck in Recovery. For a free SQLite editor, I've used aSQLite Manager. – Matthew Read Aug 10 '16 at 15:15
  • @MatthewRead OK, I'll add that to the answer too. – Dan Brown Aug 10 '16 at 20:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.