If you accidentally formatted your SD card and want to recover lost photos from reformatted memory card, an easy way is to follow this SD card photo recovery solution
However, to increase the chance of SD card recovery, you'd better stop using the SD card. Do not write any new files to the SD card. This is to prevent new files to overwrite space on formatted SD card which may make lost files unrecoverable.
It does not matter whether SD card could be from android phones, tablet, or other smartphones, digital cameras, camcorders, usb drive, or other external drive, you can unformat SD card and restore lost files.