My Android app uses a file that the user downloads, using a Web browser.
(Yes, I know that there are ways that an Android app can download a file itself, without sending the user to a Web browser. I cannot do that in this app, because the file is hosted on Microsoft's OneDrive cloud storage. And, yes, I know that there is a OneDrive API that can do that, but my understanding is that the user would need to know my OneDrive password before the API could download files.)
I would like to prevent my app from attempting to open a file while the browser is still downloading it.
I tried getting a write lock on the file, using FileChannel.tryLock(), but this granted a lock even while the browser was still downloading the file. (Apparently locking is voluntary.)
Any other ideas? Thanks.