You need to lock when you write or read a file. Thus, only one thread can access the file.
Here is the official Android site explaining the lock:
http://developer.android.com/reference/java/util/concurrent/locks/Lock.html
Here is an example of using a lock:
fooobar.com/questions/1541732 / ...
You can also use synchronization to lock the object, here it is explained:
Java sync
Source: https://habr.com/ru/post/1541730/More articles:How to use UITextfield to handle bidirectional languages (like Arabic) - iosError in kendo ui grid lrt css in chrome - cssRuby: 4-byte array for int32 - arraysHow to check node contains empty string or space or null in xpath? - xmlHow to scan Android and iOS for Bluetooth beacons without battery problems? - bluetoothBluetooth Low Energy Android - Background Search - androidJava thread synchronization - javaКак я могу сделать файл журнала из определенного файла базы данных приложения в bash? - unixDoes MySQL remove common sub-expressions between the SELECT clause and HAVING / GROUP BY - mysqlExtending the first container to display additional div attributes - pythonAll Articles