I’m trying to save and then load the files that I’ve just saved but I can’t find it.
I know it is being saved because I can look at the cache size under the Manage Application screen for the app and see that the size goes up when I save the image.
This is the error I’m getting: java.io.FileNotFoundException: /data/data/com.xxxxx/files/5ec2d71d-8a99-4258-a33a-91f6f99b8f0e.jpg
Here is my code:
imageDir = new File(context.getCacheDir().getAbsolutePath());
String newName = UUID.randomUUID().toString() + ".jpg";
Bitmap bmp = ImageLoader.getInstance().getBitmap(e.getUrl());
Boolean r = imageDir.exists();
Boolean c = imageDir.canWrite();
String[] d = imageDir.list();
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(imageDir + "/" + newName));
bmp.compress(CompressFormat.JPEG, 90, out);
out.flush();
out.close();
d = imageDir.list();
FileInputStream fis = new FileInputStream(imageDir + "/" + newName);
ObjectInputStream ois = new ObjectInputStream(fis);
Bitmap b = (Bitmap) ois.readObject();
Ideas?
Context.openFileInputopens files within your app’s data directory. What is the point of that call anyway? You already created aFileInputStream.