Search code examples
androidtext-filesexternalfile-read

Load External Text File Into Android App Without Using Resources


I have an android application I am developing in Java.

I need it to load a text file so it can read what is in the text file and get values from it.

However, everything I have read so far has been directing me to use resources and package it up with the application.

However this means if I want to change the text file, I have to reinstall the application, which is not what I want.

I need to end up with the .apk file and the .txt file in the same folder on my android phone so I can change the .txt file and the app reads in the text file in its directory.

Can anyone help?


Solution

  • No, you do not want to end up with the .apk and the .txt file in the same folder. You want to end up with the .txt in some place that's always the same and that you know about. You can deploy the initial .txt via the ressources (aka: package it and copy it to the sd for example) and later download a new version (or copy something to the device via usb).

    Then inside your app check if the file exists and open it with standard Java. There's plenty of source around for that.