I’m writing an App and an accopmanying widget that needs data. This data is downloaded over the net. I’m planning to use a IntentService to do the downloading. This service will save the data as a file. This file is then used by both the App and widget.
How can I prevent the app and widget from reading the file while the service is writing to it?
And how can i prevent the service to write to the file while the app or the widget is reading the file?
Thanks!
Consider extending
Applicationand declaring a field for reading and writing permission:Then whenever you open a
FileInputStreamor aFileOutputStream,Essentially, the field motherMayI must be true for someone to read or write the file, and its only false while its being read or written.
EDIT:
This would require an instance of
APP.