madmanul
madmanul

Reputation: 420

Android file atomic operation

I need to read some data from file in internal storage, then remove and rewrite file with new data. What is the best way to do it(safest method for data)?

Upvotes: 0

Views: 318

Answers (1)

Toon Borgers
Toon Borgers

Reputation: 3658

I'd first rename the original file (append something like .orig), then read it, write the new file and when all that's successful, remove the renamed original file. This ensures the most that no data gets lost.

Upvotes: 1

Related Questions