I'm reading an image off of the internet and trying to write it to the user's computer and then read it in future script runs. Is there a class where I can get the storage directory? I'm having trouble writing to their files
this used to be my code for it:
public static void saveImages() {
for (String s : urls) {
try {
String[] string = s.split("/");
String[] name = string[5].replace(".", "/").split("/");
File outPutFile = new File(Environment.getStorageDirectory()
+ File.separator + name[0] + ".png");
if (!outPutFile.exists()) {
RenderedImage img = getImage(s);
ImageIO.write(img, "png", outPutFile);
}
} catch (IOException e) {
}
}
}
public static void loadImage(int idx) {
String[] string = urls[idx].split("/");
String[] name = string[5].replace(".", "/").split("/");
File inPutFile = new File(Environment.getStorageDirectory()
+ File.separator + name[0] + ".png");
if (inPutFile.exists()) {
try {
images[idx] = ImageIO.read(inPutFile);
} catch (IOException e) {
e.printStackTrace();
}
}
}