0

I am using this method to retrieve a bitmap

 private Bitmap getBitmap(String url) 
{
    File f=fileCache.getFile(url);

    //from SD cache


    if(b!=null)
        return b;

    //from web
    try {
        Bitmap bitmap=null;
        Log.e("URL", url);
        URL imageUrl = new URL(url);
        HttpURLConnection conn = (HttpURLConnection)imageUrl.openConnection();
        conn.setConnectTimeout(30000);
        conn.setReadTimeout(30000);
        InputStream is=conn.getInputStream();
        OutputStream os = new FileOutputStream(f);
        Utils.CopyStream(is, os);
        os.close();

        return bitmap;
    } catch (Exception ex){
       ex.printStackTrace();
       return null;
    }
}

As you see above how do i decode the bitmap from SDcard or cache and from the get from web code? Ive tried one method but it didnt work.

1 Answer 1

1

Well for the file part take a look here. Look specifically at decodeFile.

As for the Url Image take a look here for a small tutorial on it.

Sign up to request clarification or add additional context in comments.

1 Comment

public static Bitmap decodeFile (String pathName); this needs the PathName i only have the cachefile...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.