This seems to have been answered on our Android sister-site by Chauncellor:
Well, this took a long time. For future searchers, here's what you can do:
Find your contacts2.db file hidden somewhere in Android. Most of the time it's located in /data/data/com.android.providers.contacts/databases. I was lucky and found it in a search through Titanium Backups' tarballs. Nab that file. It has everything in it in a sql database.
I then found this excellent script to extract and convert all contacts into a .vcf format for easy importing into the next device. It's located here on Github and requires two dependencies (on an Ubuntu 12.04 machine in which it was written for): sqllite3 and libsqllite3-dev:
sudo apt-get install sqlite3 libsqlite3-dev
After dependencies are satisfied, save the script on Github as dbconverter.sh. Mark it as executable:
chmod +x dbconverter.sh
use the script like this:
./dbconverter.sh contacts2.db > contacts2.vcf
You will then have a lovely .vcf file for easy importing into your phone.
There are also other programmatic approaches on SO:
.db
file to.vcf
? Because that is not the only wayfile contacts2.db
run from a terminal in the directory where the file resides.contacts2.db
is a sqlite3 database.