Thursday, June 15, 2017

4.2 jelly bean - Export list of Downloads (no root)


I was using Firefox and for some reason it deleted all downloads from the SD card.


I found an in-built app "Downloads" which has a list of all files downloaded to date, listing both Chrome and Firefox downloads.


Click Image to enlarge


Downloads


How can I export a list of filenames (and their respective URLs, if possible) shown in this "Downloads" app?




Answer



The Downloads app has the name DownloadsProviderUI (com.android.providers.downloads.ui). The entries shown by it are not handled by or stored inside its data directory. Instead, the app is just a front-end for DownloadsProvider (com.android.providers.downloads).


The information you're seeking is stored inside


/data/data/com.android.providers.downloads/databases/downloads.db

Provided that your OEM has not messed up with the manifest of DownloadProvider, you should be able to backup the app using .




  1. Setup adb in PC and connect the device, with USB debugging enabled, into PC.



  2. Launch a shell and execute the command


    adb backup com.android.providers.downloads

    Agree for the backup on the device. You should now be having a backup file named backup.ab.




  3. Follow any of the solution here to extract the content from the file. (I prefer Android Backup Extractor.)


    You should now be having a file named downloads.db, possibly under apps/com.android.providers.downloads/db/ (inside the extracted content).




  4. You now have many options to open the database file. You can use GUI solutions like Sqliteman or DB Browser for SQLite. The former one can export the data into an HTML file.



    Anyhow, inside the file, the table downloads has the relevant columns, namely: uri, title and _data.


    If you've sqlite3 installed, you can do:



    sqlite3 downloads.db
    .mode line
    .headers on
    .out info.txt
    select uri,title,_data from downloads
    .quit


    You should now be having a file info.txt. Open it and you would see a structure, such as:



    uri = http://dl-xda.xposed.info/modules/biz.bokhorst.xprivacy_v471_8ba0b6.apk
    title = XPrivacy
    _data = /data/data/com.android.providers.downloads/cache/biz.bokhorst.xprivacy_v471_8ba0b6.apk

    uri = non-dwnldmngr-download-dont-retry2download
    title = ProcessMonitor.zip
    _data = /storage/sdcard0/Download/ProcessMonitor.zip


    There exists other modes for formatting. For e.g., change .mode to csv and .out to file.csv and then keep the rest of the commands intact. Execute all the commands serially and you would end up with a CSV file.


    (You can use PRAGMA table_info('downloads') or .schema downloads to know the name of all the columns inside the table downloads.)


    If required, see this article on ZetCode to know what the aforesaid SQL commands does.




No comments:

Post a Comment

samsung galaxy s 2 - Cannot restore Kies backup after firmware upgrade

I backed up my Samsung Galaxy S2 on Kies before updating to Ice Cream Sandwich. After the upgrade I tried to restore, but the restore fails ...