• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

How to export your friends list from Facebook! (must be rooted)

zedster

Android Enthusiast
Nov 21, 2011
314
1,225
DC
I am writing a how-to guide for exporting your Facebook Friends list from any rooted android device.

As of right now the following is the only way I've seen to export your friends list from facebook to a CSV that you can upload into any e-mail client, google + or just to have outside of Facebook

What is needed:
A rooted android device
The facebook app installed
A root file manager
SQlite viewer for your Computer, I suggest the following SQLite Database Browser | Free Development software downloads at SourceForge.net
10-15 minutes


Step 1: Make sure you have the facebook app installed on your phone as well as a root file manager such as "Root Explorer"

Step 2: Open your root explorer app and navigate to /data/data/com.facebook.com/katana/databases

Step 3:Copy the facebook.db file to your sd card, this step will be different depending on what root file manager you used.
If you are using Root Explorer here are the steps:
1. long press on facebook.db until the options menus
2. select copy, the paste and cancel buttons should now appear at the bottom of the screen
3. press the parent folder button at the top of the windows until you are back in the root folder, it should now say mounted as r/o with a button to mount r/w at the top of the window
4. Scroll down to "sdcard" and click on it
5. Hit the paste button at the bottom of the screen, the file should now be on your SD Card​
Step 4: Copy the file from your SD Card to your computer

Step 5: Using the SQlite viewer open the facebook.db file

Step 6: From the file menu select export->export table as csv

Step 7: Select friend_data from the drop down menu and click export, save it where you like

Step 8: You now have a CSV file with a list of all your friends, their e-mail and birthdays from Facebook that you may do with as you please!
 
  • Like
Reactions: argedion
Great tip! I automated this a bit more for users with a linux system:

update.sh:
Code:
#! /bin/sh
adb root
adb pull /data/data/com.facebook.katana/databases/fb.db
sqlite3 -csv -header fb.db "select display_name,last_name,first_name,email,cell,other,birthday_year,birthday_month,birthday_day,user_image_url from friends;" > friends.csv
perl friend_frob.pl friends.csv > friends.vcf
friend_frob.pl:
Code:
#!/bin/perl

use strict;
use warnings;
use Text::CSV;

my $csv = Text::CSV->new ({ binary => 1 });
my $file = $ARGV[0];
open(my $data, '<', $file) or die "Could not open '$file'\n";

$csv->column_names ($csv->getline ($data));
while (my $fields = $csv->getline_hr ($data)) {
    print "BEGIN:VCARD\n";
    print "VERSION:3.0\n";
    printf ("FN:%s\n", $fields->{display_name});
    printf ("N:%s;%s;;;\n", $fields->{last_name}, $fields->{first_name});
    if ($fields->{email} ne "") { printf ("EMAIL;TYPE=INTERNET:%s\n", $fields->{email}); }
    if ($fields->{cell} ne "") { printf ("TEL;TYPE=CELL:%s\n", $fields->{cell}); }
    if ($fields->{other} ne "") { printf ("TEL:%s\n", $fields->{other}); }
    if ($fields->{birthday_day} != -1) {
    if ($fields->{birthday_year} == -1) {
        printf ("BDAY:%s/%s\n", $fields->{birthday_month}, $fields->{birthday_day}); 
    } else {
        printf ("BDAY:%s-%s-%s\n", $fields->{birthday_year}, $fields->{birthday_month}, $fields->{birthday_day});
    }
    }
    printf ("PHOTO;VALUE=URL:%s\n", $fields->{user_image_url});
    print "END:VCARD\n";
}

Now all the data is in a standard vCard file.
 
  • Like
Reactions: argedion
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones