I'm sure it's possible, but probably a lot more work to do it that way than it's worth (unless this is a session in learning data recovery programming).

I'd probably use a program like R-Studio or R-Linux to carve out the files. You can even define custom file signatures using R-Studio so you can fully control how it's carving out the data.
_________________Lead Data Recovery Tech at Data Medics® - www.data-medics.com

This looks nice but it seems to be private for their own use. Wonder how would it handle corrupted databases like after factory reset when you get only part of the file.

Hello! No, this program not for personal use, you can receive a demoversion.
Uniqueness of the program - the fact that she works with the records SQLite. If the file is damaged, the program anyway will take and will provide you reports of the database.