From a high level: you're going to need an "before" copy of the file and an "after" copy of the file. Once you detect that a change has occured you need to compare the two copies of the file.
The easiest way to do a file-change detection would be to just check the modified timestamp on the file. If you're sure you can loop once per second then just see if the timestamp is >= (now - 1)
. Otherwise, store the old modified time and check to see if the current modified time is larger.
The tricky part is in doing the comparison between the two versions. There are several algorithms to do binary diffs out there, but they're all going to be slow... like O((n+m) log n)
slow. Check out the algorithm that bsdiff uses as it's one of the faster ones out there. It might also be wise to look in to the Android NDK for this. This is one of the few things native C will do better than dalvik/Java.
One way you could speed up the diff process would be to split the file into a bunch of chunks, hash the chunks, then compare the hashes each go around. You'd only need to do binary diffs for the chunks that have different hashes. If you decide to go this route look into checksums.
Good luck... there aren't really any good solutions for this on a mobile device as it's an inherently resource intensive process.