- Getting the app data from the phone
Unfortunately Firefox for Android does not offer export, or as the matter of fact import, functionality of bookmarks stored on the device. The only official way to get bookmarks from the Android version of Firefox is to use the sync service. Since I was decommissioning my old phone from everyday use, I was only interested on saving them onto my computer once, without registering for a sync account.
Getting the app data from the phone
Please note that this method only works if you have root access on your phone!
Creating a data dump via backup
In order to transfer Firefox profile data first I had to get a tarball of it
from my phone to my laptop. The easiest way to do it was to install
oandbackup and then create a
backup of the Firefox application. It’s sufficient only to create backup of the
DATA, as the
APK should not be required for this.
Creating Firefox data backup on Android
Transferring data to the laptop
Once backup was complete, I transferred the resulting
oandbackups/org.mozilla.firefox/ using Bluetooth, but other methods
could have been also used, like
adb or plain old USB Mass storage.
$ adb pull /sdcard/oandbackups/org.mozilla.firefox/org.mozilla.firefox.zip $ unzip org.mozilla.firefox.zip
Finally I unzipped the backup so I could examine it further.
…the user profile data
Looking at the extracted directory it was quite obvious, that Firefox on Android
stores it’s data in a similar structure as on a PC. First I needed the profile
directory, which usually has a name of
XXXXXXX.default, where XXXXXXX is
some random string. After poking around surely enough there it was:
$ cd org.mozilla.firefox/ $ find . -name *.default -type d ./files/mozilla/znuyc0q3.default ./cache/znuyc0q3.default $ cd files/mozilla/znuyc0q3.default
…the bookmark storage
The contents of the profile directory have pretty descriptive names, so I was
looking for something either named bookmarks or some form of database where
such information could be stored. There was no file named bookmarks, but there
were databases named either
*.sqlite. Looking at the search
results there were only two reasonable candidates as possible bookmark storage.
$ find . -name "*.sqlite" -type f ... ./storage.sqlite ... $ file storage.sqlite storage.sqlite: SQLite 3.x database, user version 131073, last written using SQLite version 3020001 $ find . -name "*.db" -type f ... ./browser.db $ file browser.db browser.db: SQLite 3.x database, user version 39, last written using SQLite version 3009002
Fortunately both of these files are SQLite databases, so it was fairly straightforward to examine them.
$ sqlite3 storage.sqlite '.tables' $ $ sqlite3 browser.db '.tables' activity_stream_blocklist logins android_metadata logins_disabled_hosts bookmarks metadata bookmarks_with_annotations numbers bookmarks_with_favicons page_metadata clients remote_devices combined searchhistory combined_with_favicons tabs deleted_logins thumbnails favicons urlannotations history visits history_with_favicons $ sqlite3 browser.db '.schema bookmarks' CREATE TABLE bookmarks(_id INTEGER PRIMARY KEY AUTOINCREMENT,title TEXT,url TEXT,type INTEGER NOT NULL DEFAULT 1,parent INTEGER,position INTEGER NOT NULL,keyword TEXT,description TEXT,tags TEXT,favicon_id INTEGER,created INTEGER,modified INTEGER,guid TEXT NOT NULL,deleted INTEGER NOT NULL DEFAULT 0, localVersion INTEGER NOT NULL DEFAULT 1, syncVersion INTEGER NOT NULL DEFAULT 0, FOREIGN KEY (parent) REFERENCES bookmarks(_id)); CREATE INDEX bookmarks_url_index ON bookmarks(url); CREATE INDEX bookmarks_type_deleted_index ON bookmarks(type, deleted); CREATE UNIQUE INDEX bookmarks_guid_index ON bookmarks(guid); CREATE INDEX bookmarks_modified_index ON bookmarks(modified); $ sqlite3 browser.db 'select url from bookmarks where url not NULL' https://... ...
browser.db had the information I was looking for, and I was only two
simple queries away from getting the list of bookmarks I saved for later