Android Question Looking for Corrupted file recovery ideas


Active Member
Licensed User
Longtime User
I am writing string to a txt file every 3 minutes.
But now getting some corrupted files when device battery flap or manual device restart when writing taking place.
I've gotten a idea but don't know if it is the best way to do this.
My idea is to..
write to file1 the string ...
sleep 1 sec
write to file2 the same string....

Now try to read file1 , on error catch with read file2...
Do i need the sleep ?
Is there a better way?