FileSync — The Android app I made for synchronising files & folders between devices
Tags: android, programming, java
Published: 2022-03-09 14:08:49

A few years back, after sitting in traffic for an hour listening to the radio, having forgotten to put the SD card with all my music on back into the car, I had one of those “there has to be a better way” moments. See, my car’s SD slot is the perfect way to store my library of music for easy access, but it’s not the perfect way to keep that library up to date. For that, I have to remove the SD card, take it to my PC, add and delete any recent changes to my library, eject it, and then take it back to the car. Enter, FileSync.

FileSync is an Android app which I wrote to solve this exact problem, but ended up just flexible enough to solve a few more too. FileSync is a super simple file synchronisation app, where you add a series of “Synchronisations” that can be called upon quickly and easily. These synchronisations might be from one folder on your phone to another, or from a network share to your phone, or — and here’s my use case — from a network share to a connected USB device.

Thanks to this latter use case, my process for keeping the music in my car up to date got a whole lot easier. Now, when I know I have new music sitting in my library, and I have that “Ah ****, I’ve forgotten to put the new stuff on my SD card” moment whilst sat in the driver’s seat, I just connect the SD card to my phone (using an SD card adapter with USB-C), open FileSync, and run the “Car music” job. It blitzes through the changes, comparing all my existing files to make sure nothing needs deleting or updating, and moments later I can put the SD card back in my car and I’m good to go.

<figure>
  <img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8lsnnjse2d5b6oc4yjqm.png" alt="my alt text"/>
  <figcaption>The actual intended purpose of FileSync: Network share to USB!</figcaption>
</figure>

Now, I appreciate the niche nature of this app. I’m under no illusions that I’ve discovered the next “IFTT” here. This whole project was a purely technical experimentation that combined some Android programming with the use of the fantastic [JCIFS SMB library](https://www.jcifs.org/). FileSync was a bit of a passion project, but it is by no means a polished or professional job. That said, it is of course [free and open-source](https://github.com/DuncanMcArdle/FileSync), so there’s only so much you can complain about!

As part of FileSync’s creation, I got to learn about some really cool technologies in the world of file management. I implemented a custom SMB browser, battled (and eventually lost) against the much more frustrating world of calculating and comparing file hashes over a network without it taking forever (spoiler alert: you can’t, so comparing file names and sizes is as good as you’ll get), and just generally got to understand how Android systems such as DocumentFile work these days.

![A quick preview of how FileSync works](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o7q3gj5ib9lcthswwu3r.png)
![A quick preview of how FileSync works](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5k9jw2cjxhtm1c20m3da.png)
![A quick preview of how FileSync works](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s3trofte8zv4oy0qa3hg.png)
 
The app itself isn’t currently on the Google Play store, as that’s a whole different beast by itself, and perhaps more so because this was just a proof of concept, not a release-ready app. But of course you’re welcome to download, build and even change the source code, [which is on GitHub](https://github.com/DuncanMcArdle/FileSync).

Whilst writing this blog post up, I’ve already started to think of a few potential uses for FileSync, like saving photos on the phone to a connected USB stick, or easily backing them up to a network share, but I’m sure there are plenty more. Maybe if I think of one valuable enough to have even small-market appeal, I might go to the trouble of getting it on Google Play!