How can I recover files from a phone that won't boot? I have a Galaxy SII, and it is stuck on the boot screen. How can I recover the files on the phone?
I had the same problem with stock Nexus 7 2012 GSM.

The relevant documentation for this is


https://support.google.com/nexus/answer/4596836?hl=en the Recovery mode section
https://developers.google.com/android/nexus/images section Flashing instruction (it helps you get familiar with adb and fastboot)
https://developer.android.com/tools/help/adb.html ADB manual


First of all, the bootloader has to be unlocked.

fastboot oem unlock


Unlocking the bootloader deletes user data on the device (as a security precaution). If you haven't unlocked the bootloader before, you are now out of luck. Try to find if you have backups. (Contact data may be synced with your Google account, you might have Dropbox installed, G+ backups photos and so on).

Assuming unlocked bootloader, you can flash a custom recovery which will allow you to access data on the phone.

I tried ClockworkMod, but after I booted into it, adb listed my tablet as unauthorized device, similarly as this person describes. He solved the problem, I did not.

Therefore I next tried TWRP recovery.

fastboot flash recovery path_to_twrp.img


With TWRP, adb devices listed my device with recovery permissions (whatever it means) and I could copy out my data

adb pull /data .


In addition TWRP seems to enable MTP on the device. That is another possible way to get data out. I haven't experimented with it, because I did adb pull first and I got my data that way. Additionally, in my experience, MTP clients for Linux are rather flaky.