Allow changing Recordings Folder and keeping list of starred files + workaround
Currently, if the user moves their entire collection of files to a different directory, and then sets Audio Recorder's Recordings Folder to point to the new folder, all the user's starred files will no longer be starred. This is because the call to hashCode()
uses each file's full path, instead of just the filename alone:
Implementing this feature will be a bit tricky, because you need to keep compatibility with users' existing starred file lists, where the entire file paths were hashed. And Audio Recorder shouldn't just move the files itself, since at worst it may not preserve files' timestamps in the move, and/or risk corrupted data by not doing a second pass for copy verification. The actual moving of files should be left to the user. (Implementing a solution that breaks compatibility with previous versions' starred file lists would be much worse than doing nothing, because there is a workaround below that is usable now.)
In the meantime, there is a workaround! I found that the Java hashCode()
algorithm is coincidentally perfect for this. Adding a calculated 14 character suffix to the new directory allows all the file path hashes to be preserved without change, meaning the list of starred files will be carried over. This program calculates a 14 character suffix that will do the job:
Audio Recorder / Audio Library starred file hashcode directory move calculator
So for example if the current Recordings Folder is set to /storage/emulated/0/Android/data/com.github.axet.audiorecorder/files/recordings
and you want to move to /storage/external_SD/Audio Recorder
, then move them actually to a directory /storage/external_SD/Audio Recorder/yv_ll
x^vda]eg. Or if you want the 14 characters to be a suffix rather than a subdirectory, change the trailing
/in the target directory to a
and you'll get
/storage/external_SD/Audio Recorder zd_reil^vda]eg` as the directory to move your files to.
Simply copy/move the files to the new directory, then change Audio Recorder's Recordings Folder to point to the new folder outputted by the above program.
I worked this out for a friend who uses Audio Recorder and has thousands of recordings and hundreds of starred files. He ran out of internal storage on his tablet and needed to move the files to an SD card, but also needed the list of starred files to be preserved.