Reputation: 420
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
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