I have an Android activity that gets a list of files from a directory using the File.listFiles() function. This returns an array of Files exactly as I’d expect. This activity has the option to start another activity which allows users to create a new file in the same directory.
When I return from the second activity, having created a new file, I call the File.listFiles() function again to get the updated list, but the returned array doesn’t include the newly generated file.
When I restart the app the filelist is correct with the newly created file included. It is as if the Activity is caching the result or not re-checking the directory.
Anyone else had this problem and/or know how to fix it?
Many thanks,
Chris
I’ve managed to fix this now. The problem was caused by the fact I was writing the files in the second activity’s onStop() function which appeared to be called after the first activity’s onResume(). I’ve chnaged the code to save onBackButtonPress() and everything now works as expected.