I am getting a person's facebook profile picture, and I want to save it into my local storage so it can be recovered and shown later.
I did everything this link said, but I am getting an exception on the BitmapFactory.decodeStream line AND I can't see what the exception is, when I debug, the debugger goes directly to the "return null" line and I can't evaluate the "e" variable.
here's my code:
InternalFileHelper.cs:
public void saveToInternalSorage(File mypath, Bitmap bitmapImage){
        FileOutputStream fos = null;
        try {
            if (!mypath.exists()) {
                fos = new FileOutputStream(mypath);
                // Use the compress method on the BitMap object to write image to the OutputStream
                bitmapImage.compress(Bitmap.CompressFormat.PNG, 100, fos);
                fos.close();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        //return directory.getAbsolutePath();
    }
    public Bitmap loadImageFromStorage(File f)
    {
        try {
            if (f.exists()) {
                Bitmap b = BitmapFactory.decodeStream(new FileInputStream(f));
                return b;
            }else
                return null;
        }
        catch (FileNotFoundException e)
        {
            e.printStackTrace();
            String mess = e.getMessage();
            return null;
        }
    }
Here's how I save the image:
ContextWrapper cw = new ContextWrapper(getApplicationContext());
// path to /data/data/yourapp/app_data/imageDir
File directory = cw.getDir("imageDir", Context.MODE_PRIVATE);
// Create imageDir
File mypath=new File(directory,this.fbId.toString()+".png");
InputStream inputStream;
HttpGet httpRequest = new HttpGet(URI.create("http://graph.facebook.com/" + this.fbId.toString() + "/picture?type=normal"));
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response = (HttpResponse) httpclient.execute(httpRequest);
HttpEntity entity = response.getEntity();
BufferedHttpEntity bufHttpEntity = new BufferedHttpEntity(entity);
Bitmap bmp = BitmapFactory.decodeStream(bufHttpEntity.getContent());
httpRequest.abort();
this.image = bmp;
helper.saveToInternalSorage(mypath, bmp);
and here's how I recover the image:
ContextWrapper cw = new ContextWrapper(getApplicationContext());
// path to /data/data/yourapp/app_data/imageDir
File directory = cw.getDir("imageDir", Context.MODE_PRIVATE);
// Create imageDir
File mypath=new File(directory,this.fbId.toString()+".png");
InternalFileHelper helper = new InternalFileHelper();
Bitmap image = helper.loadImageFromStorage(mypath);
It's driving me nuts!! thanks in advance!!
 
    