Change primary Google account on Android phone

There are a lot of questions around the net how to change default google account which is used in Talk, Market and other google properties. Standard answer is to do factory reset, but if you used Android for a while like me, it's nor really a solution.

It turns out is simpler than that:

dpavlin@t61p:~$ adb shell
# sqlite3 /data/system/accounts.db
SQLite version 3.6.22
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> delete from accounts ;
Now you can go into Dailer application and under Contacts add one account which you want to be new primary account used by various Google apps. Now go to Talk and try to login.
After sucesfull login in Talk with new primary account, go into Contants and add other accounts. I suggest to turn off Contacts sync with primary account it you haven't had it on before to prevent flooding of your Android with gmail contacts.