Search code examples
javaandroidwebserver

Compare local text file with server text file


I have a file on my server called "questions.txt" where questions are stored. In my app i have a raw res folder where there is also a "questions.txt". I have a few things i want to do, and have no idea how:

  1. Prevent the user from editing the text file himself with a file explorer

  2. On app start, compare the local text file with the server one and update the local one if necessary.

  3. Obviously make everything as safe as possible.

I hope you can help me or give me an idea on how to achieve this.

Dave


Solution

  • 1: You cannot really prevent this if the user has root permissions unless you find a way to encrypt the data and manage to hide the implementation of the app to decrypt it.

    2: If the file is pretty big you could make a hash of the file and compare that to a server side hash of the file to save data transmitted.

    3: Don't use a plain HTTP connection again, look for ways of encryption and decryption. HTTPS would be suitable for this.