but what if that data isn't that stupid like "txtdata" but something more like progress in a game, how to save this? I could do it like this but then the player can just alter the progress in the game with a text-editor so it has more abilities or something like that. I would like to prevent this by writing to a protected location or a password-protected file, especially on Android. What is the right approach?

Hi! One simplistic approach that comes to my mind: Once you want to save the contents to your file.txt, take this content, append a secret string to it and compute a hash over everything. Then save the content (without the secret, of course) to a file. Also save the computed hash to another file. Next time, your application reads the two files, recomputes the hash and checks if they match.