In my app (Android) I create a file. To this file I add a line by line after some situation. Then I send a data to the server line by line. When all transmission is OK I erase the file, like this:
fos_kasowanie_pliku = openFileOutput(FILENAME, Context.MODE_PRIVATE);
fos_kasowanie_pliku.write("".getBytes());
fos_kasowanie_pliku.close();
Can I delete only 1 line (first one) after sending this to the server? I read that I should rewrite the file without this line. Is there a better solution?
You may consider using a database, where you can add records, then send the data to the server, and then delete records in any order you prefer. Databases, unlike plain old files, are designed to handle exactly the problem you are describing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With