In my android app, I make files in a directory I get using this function (notice its putting in a subdirectory).
gsFile = new File(getCacheDir(), "test/aa.txt");
But how do I iterate through the files in that directory now?
I tried
File dir = new File(getCacheDir(), "test/aa.txt");
for (File f : dir.listFiles()) {
}
but it crashed on File f
At the top-right, tap on the three vertical dots to open the Chrome options menu. Tap History. Check “Cached images and files.”
Android cache files can be saved both on Android internal memory and external SD card. If you completely deleted the folder without doing backups, your data in Android internal memory or some of the external memory SD card will be removed.
On Android Studio you can use Device File Explorer to view /data/data/your_app_package/cache. Click View > Tool Windows > Device File Explorer or click the Device File Explorer button in the tool window bar to open the Device File Explorer.
Change your code like this and try..
File dir = new File(getCacheDir(), "test");
if (dir.exists()) {
for (File f : dir.listFiles()) {
//perform here your operation
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With