I'm trying to import a list of words into an arraylist from a .txt file. Right now i'm placing my .txt file into the assets folder. So far i can do this using the following code
try {
AssetManager am = this.getAssets();
InputStream inputStream = am.open(inputFile);
if (inputStream != null) {
InputStreamReader streamReader = new InputStreamReader(
inputStream);
BufferedReader bufferedReader = new BufferedReader(streamReader);
String line;
while ((line = bufferedReader.readLine()) != null) {
words.add(line);
}
}
inputStream.close(); // close the file
} catch (IOException e) {
e.printStackTrace();
}
I then want to be able to shuffle my arraylist and put the words back into the same .txt file, so that the next time I open the app it will import the shuffled list. But it turns out you can't write to files in the asset folder. Is there a different way to import words from a .txt file and still be able to export to that same .txt file? Where do I need to put my .txt file?