Stuck in boot after changing dpi - Lenovo a7000 I used  Texdroider DPI  to change the dpi from 320 to 300 and after the reboot it gets stuck at the lenovo logo. I could just flash it again but i don't have the rom on this pc, and it will take 10h to download it.

Is there any faster way to reset the dpi? I have TWRP installed. With android 5.0.1.

Edit:
Output of cat /system/build.prop | grep density is ro.sf.lcd_density=300
Tried editing build.prop back to 320 with Sublime Text. Now the command returns ro.sf.lcd_density=320 but it still gets stuck.
Note: 


Parts of this answer didn't work for OP, but nevertheless, they worked in all of my test cases with different ROMs, hence, the answer  would certainly prove to be useful for some users.
Device should have a custom recovery installed.
adb should be setup in PC and USB debugging be enabled and authorized in the device.
Anything mentioned next to # anywhere in a line is a comment.




More or less, the changed DPI value would either be in settings.db, /data/property/persist.sys.lcd_density, /system/build.prop or in memory only. I've covered instructions for all of these cases and they should prove to be helpful when the device gets stuck at boot animation. 


If it is an Xposed module which changed the DPI and caused boot issue, then try disabling the module or the framework, or, remove the former or both. See my answer here for more info on that.
If you used command-line to change DPI (am/wm), then when the device gets stuck at boot animation (past the OEM logo), execute 

adb shell am display-density reset    # For Android 4.2.x
adb shell wm density reset            # For Android 4.3.x and above
adb reboot

In my Android 4.2.1, custom display density is saved as a value for the key display_density_forced in the table global of /data/data/com.android.providers.settings/databases/settings.db. If you've used command-line (am) or an app used this key, follow these steps:


When booted into recovery, mount data partition, pull the said file into PC and use an sqlite editor to either remove the key or change the value to a better or default DPI. After that, push the file back to its place.

adb pull /data/data/com.android.providers.settings/databases/settings.db LOCAL_PATH     # to pull the file into PC
adb push LOCAL_PATH/settings.db /data/data/com.android.providers.settings/databases/    # to push the file into Android
adb reboot 


Replace LOCAL_PATH with the directory under which settings.db is to be saved and is saved, respectively.


In Android 4.3 and above, custom display density can be found under /data/property/persist.sys.lcd_density or by executing adb shell "getprop | grep density". If you used command line (wm) or an app used that property to change DPI then follow these steps:


When booted into recovery, mount data partition and do

adb shell rm /data/property/persist.sys.lcd_density                      # this will cause Android to fall back to default DPI
adb shell busybox printf "DPI" &gt; /data/property/persist.sys.lcd_density  # change DPI with your custom DPI value
adb reboot


Finally, the easiest but a dangerous and extreme approach you or an app would take is to change the DPI for the key ro.sf.lcd_density inside /system/build.prop. The DPI in the said file is considered the stock DPI of that ROM.

When booted into recovery with data partition mounted,


You can choose to override the stock DPI by doing

# replace DPI with your custom DPI
adb shell am display-density DPI   # For Android 4.2.x only 
adb shell wm density DPI           # For Android 4.3.x and above only 
adb reboot

If that doesn't work for some reason, do

adb shell sed -i 's/.*ro.sf.lcd_density.*/ro.sf.lcd_density=DPI/g' /system/build.prop      # sed is replacing the DPI with your custom DPI value
adb reboot

If none of the solutions work then your only option is to replace build.prop. If you've a clean backup of system partition or build.prop then use it to replace original file, else flash the ROM as OP did.



Note: I personally did not test, but it has come to my notice to not edit any file of Android using any native text editor of Microsoft Windows OS. Instead, use Notepad++ or altogether do all the editing using command line in recovery.