recovering contacts from apk file



  • I have backups made using OAndBackupX from my android phone and would like to recover my contacts from there. From looking around, I see that I have a directory called com.android.contacts which has in it a Contacts.apk file and a data.tar.gz file (which has shared_prefs/com.android.contacts.xml, which does not appear to be that useful) inside it. Is it possible to get my contacts (name and phone number) from this apk list? If so, how?

    The Contacts.apk file opens into a bunch of folders and files:

    AndroidManifest.xml  classes.dex  META-INF/  resources.arsc
    assets/              com/         res/       shared_prefs/
    

    Which, if any, of these would have the data I am looking for?



  • After mucking around a bit, I have been able to get enough information to reconstruct my contacts information. Thank you to @Izzy for pointing it out to me.

    I obtained my ContactsProvider.apk from my backup and also data.tar.gz and device_protected_files.tar.gz.

    I then unzipped my ContactsProvider.apk using unzip ContactsProvide.apk and got:

    databases/  files/  shared_prefs/
    

    The databases

    calllog.db          contacts2.db  profile.db
    calllog.db-journal  profile.db-journal
    

    It would perhaps make sense that contacts2.db would have this information, so I looked into this sqlite3 file (as it is what I found below):

    $ file contacts2.db 
    contacts2.db: SQLite 3.x database, user version 1400, last written using SQLite version 3022000
    

    $ sqlite3 contacts2.db
    SQLite version 3.36.0 2021-06-18 18:36:39
    Enter ".help" for usage hints.
    sqlite> .tables
    _sync_state phone_lookup view_data_usage
    _sync_state_metadata photo_files view_entities
    accounts pre_authorized_uris view_groups
    agg_exceptions presence view_metadata_sync
    agg_presence properties view_metadata_sync_state
    android_metadata raw_contacts view_raw_contacts
    contacts search_index view_raw_entities
    data search_index_content view_stream_items
    data_usage_stat search_index_docsize view_v1_contact_methods
    default_directory search_index_segdir view_v1_extensions
    deleted_contacts search_index_segments view_v1_group_membership
    directories search_index_stat view_v1_groups
    groups settings view_v1_organizations
    metadata_sync status_updates view_v1_people
    metadata_sync_state stream_item_photos view_v1_phones
    mimetypes stream_items view_v1_photos
    name_lookup v1_settings visible_contacts
    nickname_lookup view_contacts
    packages view_data

    Carrying on with the above, I did the following:

    $sqlite contacts2.db
    sqlite> .separator , # to get the information in a CSV file with comma separation
    sqlite> .output raw_contacts.csv #Where to save the file
    sqlite> select * from raw_contacts; # Get it from raw_contacts in in the table above
    sqlite> .exit
    

    Then the file raw_contacts.csv has the information I want. There are several tables that have this information, and I just think that this one is fine from the ones I tried. Perhaps there are others that are better.


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2