Here is my code when I am writing to the file
Bitmap bitmap;
InputStream is;
try
{
is = (InputStream) new URL(myUrl).getContent();
bitmap = BitmapFactory.decodeStream(is);
is.close();
//program crashing here
File f = File.createTempFile(myUrl,null,MyApplication.getAppContext().getCacheDir());
FileOutputStream fos = new FileOutputStream(f);
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fos);
fos.flush();
fos.close();
}
catch(Exception e)
{
bitmap = null;
}
And here is my code reading from the same file
Bitmap bitmap;
try
{
File f = new File(myUrl);
FileInputStream fis = new FileInputStream(f);
BufferedInputStream bis = new BufferedInputStream(fis);
byte[] bitmapArr = new byte[bis.available()];
bis.read(bitmapArr);
bitmap = BitmapFactory.decodeByteArray(bitmapArr, 0, bitmapArr.length);
bis.close();
fis.close();
}
catch(Exception e)
{
bitmap = null;
}
The program is crashing at the creation of the temp file in the first chunk of code.
EDIT: I am getting a libcore.io.ErrnoException