FORUMS

Extract Android SQLite Databases For Contacts, SMSs, Etc

13 posts
Thanks Meter: 2
 
By k420, Junior Member on 15th July 2010, 10:29 AM
Post Reply Email Thread
Hi All,

I'm a Windows/Web/Database developer and I've decided to bite the bullet and learn some Java and write apps for Android. I've done Hello World and a few other programs and now I want to start playing with things like contacts and SMSs.

To make life easier I want to get copies of the various SQLite databases so that I can write my SQL queries and general play with them in my SQLite admin program on Windows.

I assume that they are just regular SQLite files like I've used in other projects so what I'd like to know if possible is:
  1. Is my assumption about them being regular SQLite files correct?
  2. Where do they live on the phone?
  3. How do I get them off the phone/emulator?
Also, I don't know whether it makes a difference to what I want to do but I've not rooted my phone and don't really want to. Based on that, if it needs rooting to get them I'd be really grateful if anyone happens to have gone through this exercise before and can just attach them to a reply post.

Thanks for your time in advance
16th July 2010, 08:52 AM |#2  
OP Junior Member
Thanks Meter: 2
 
More
For anyone who's interested, after a load of digging I've found the following:

Contacts = /data/data/com.android.providers.contacts/databases/contacts.db
SMS = /data/data/com.android.providers.telephony/databases/mmssms.db
Bookmarks = /data/data/com.android.browser/databases/browser.db

You can get them off the emulator using the adb pull command. E.g.

adb pull /data/data/com.android.providers.contacts/databases/contacts.db d:\contacts.db

Cheers
The Following 2 Users Say Thank You to k420 For This Useful Post: [ View ] Gift k420 Ad-Free
16th March 2016, 08:51 PM |#3  
Junior Member
Thanks Meter: 2
 
More
Quote:
Originally Posted by k420

For anyone who's interested, after a load of digging I've found the following:

Contacts = /data/data/com.android.providers.contacts/databases/contacts.db
SMS = /data/data/com.android.providers.telephony/databases/mmssms.db
Bookmarks = /data/data/com.android.browser/databases/browser.db

You can get them off the emulator using the adb pull command. E.g.

adb pull /data/data/com.android.providers.contacts/databases/contacts.db d:\contacts.db

Cheers

Adding one for Calls :

Calls -
Code:
/data/data/com.android.providers.contacts/databases/contacts2.db
Example to access :
Code:
[email protected]:/ #  sqlite3 /data/data/com.android.providers.contacts/databases/contacts2.db
providers.contacts/databases/contacts2.db                                     <
SQLite version 3.7.11 2012-03-20 11:35:50
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .headers on
.headers on
sqlite>.mode column
.mode column
sqlite> select _id,number+random(),duration,name contact_name ,datetime(date/1000, 'unixepoch', 'localtime') timestamp
from calls
where number not like '1832%'
order by _id desc
limit  0 , 6 ;

_id         number+random()       duration    contact_name  timestamp
----------  --------------------  ----------  ------------  -------------------
16396       -7814232970342288419  0                         2016-03-16 14:59:53
16395       -2897789212886021933  112                       2016-03-16 14:27:11
16393       -5099152494103830835  262         Rajaselvam M  2016-03-16 12:28:56
16389       8412659988096325402   13                        2016-03-16 09:36:48
16385       1480282204589577101   125         அம்ம  2016-03-16 08:05:07
16384       -1575337348523869115  0           Saami         2016-03-15 22:05:50
sqlite>
The Following 2 Users Say Thank You to kesavan2000in For This Useful Post: [ View ] Gift kesavan2000in Ad-Free
27th November 2017, 05:22 AM |#4  
Junior Member
Thanks Meter: 0
 
More
this is great, i dont suppose you have some code to extract sms and contacts as well do you.

i copy pasted your above code into db browser for sqlite and it worked great.

but i do not know how to write the code myself
21st June 2018, 10:20 PM |#5  
Junior Member
Thanks Meter: 0
 
More
I lost my android device but need the contacts from it...HELP!
is there any way i can extract this data from my Mac computer or do I have to do it from the android device? cause I lost the actual phone and for some reason the last month or so of contacts inputted werent backed up to my google account.
6th September 2018, 06:18 AM |#6  
damastah's Avatar
Senior Member
Flag Desert Hot Springs
Thanks Meter: 62
 
More
Quote:
Originally Posted by [email protected]

is there any way i can extract this data from my Mac computer or do I have to do it from the android device? cause I lost the actual phone and for some reason the last month or so of contacts inputted werent backed up to my google account.

You have to grab the actual file in order to read your contacts. The only way you'd have it on your mac is if you did a root backup of your phone.
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes