Reputation: 44230
I am trying to read a file I already created in the application's cache directory
yes I used File (java.io.File) to create the file in the cache directory, I use file to check to see if the created file exists
but in another class I need to open that file (a class that isn't called unless the file exists), I want to use openFileInput(String filename) but openFileInput doesn't allow file paths! it also doesn't default to the cache directory, what a conundrum! (using debugger to watch all the various exceptions that openFileInput will throw, it either gives file not found or illegal arguments when a path name is input)
I need another way to get at this file. Everything worked when I was reading and writing to storage, but I need to use cache.
Upvotes: 0
Views: 1096
Reputation: 1006614
I want to use openFileInput(String filename) but openFileInput doesn't allow file paths!
Of course.
it also doesn't default to the cache directory
It is not supposed to.
I need another way to get at this file.
Use Java file I/O, the same way you created the file. As you (hopefully) used when you created the file, getCacheDir()
returns the application's cache directory. Use the same File constructor you used to write to the file to read from the file.
Upvotes: 1