Can the disk digger app restore a file even after factory reset
Yes, but not reliably.

If you want to prevent this, zero and/or encrypt your device.

If you want to maximize file recovery do as little as possible with the phone and backup with adb pull /dev/block/mmcblk0 mmcblk0.img from recovery (tested with TWRP) then use photorec.