Reputation: 4960
Upvotes: 4
Views: 1213
Reputation: 9814
You need to lock when you write or read your file. This way only one thread can access the file.
Here is the official android website explaining a lock:
http://developer.android.com/reference/java/util/concurrent/locks/Lock.html
Here is an example using a lock:
https://stackoverflow.com/a/3392615/2767703
You can also use synchronized to lock an object, here is it explained:
Upvotes: 1