Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5985369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:31:13+00:00 2026-05-22T22:31:13+00:00

I would like to use Android’s system cache when downloading images as per these

  • 0

I would like to use Android’s system cache when downloading images as per these previous instructions: android system cache. I was able to get the following code working but the log statements are telling me that the images are never being read from the cache.

try {
    //url = new URL("http://some.url.com/retrieve_image.php?user=" + username);
    URL url = new URL("http://some.url.com/prof_pics/b4fe7bdfa174ff372c9f26ce6f78f19c.png");
    URLConnection connection = url.openConnection();
    connection.setUseCaches(true);
    Object response = connection.getContent();
    if (response instanceof Bitmap) {
        Log.i("CHAT", "this is a bitmap");
        current_image.setImageBitmap((Bitmap) response);
    }
    else {
        Log.i("CHAT", "this is not a bitmap");
        Log.i("CHAT", response.toString());
        InputStream is = connection.getInputStream();
        BufferedInputStream bis = new BufferedInputStream(is);
        current_image.setImageBitmap(BitmapFactory.decodeStream(bis));
    }
} catch (MalformedURLException e) {
    e.printStackTrace();
} catch (IOException e) {
    e.printStackTrace();
}

I have tried two different types of requests, one is to go through a PHP script that returns the image and another that is directly accessing the image file. I refresh the same image multiple times in a row and it never seems to get cached. For the direct image access, I get:

05-31 23:45:12.177 I/CHAT    ( 2995): this is not a bitmap
05-31 23:45:12.177 I/CHAT    ( 2995): org.apache.harmony.luni.internal.net.www.protocol.http.FixedLengthInputStream@40c1c660`

For the indirect image access, I consistently get:

05-31 23:45:14.550 I/CHAT    ( 2995): this is not a bitmap
05-31 23:45:14.550 I/CHAT    ( 2995): org.apache.harmony.luni.internal.net.www.protocol.http.ChunkedInputStream@40c02448
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T22:31:14+00:00Added an answer on May 22, 2026 at 10:31 pm

    I found a better way to do it. If anyone else is having trouble after following the link android system cache, use this Google developer’s blog post instead. The source code in that blog post is designed for a ListView but I am using it for all image retrievals. It downloads the image in an AsyncTask, puts a temporary image while downloading, and has an image cache. This last part is listed as a “Future Item” in the blog post, but if you download the source code, the cache is implemented. I had to modify the code slightly because the AndroidHttpClient isn’t supported in 2.1. I switched it to a URL connection. So far, this looks to be a great image downloader class. Let’s just hope it doesn’t impact our already struggling memory management issues.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to use javascript to develop general-purpose GUI applications. Initially these are
I would like to use Android phones as a way to do some processing
I'm working on an Android app in which I would like to use multi-touch.
I'm trying to develop an Android RSS Reader. I would like to use android.sax
I would like to use cURL library in my android application in native code
i would like to use the accelerometer in an Android Handset for my Application.
I would like to use Charles web proxy to work with the Android emulator
I would like to use a .jar file generated by SWIG in an Android
I would like to use the Android animation framework to calculate movement over time.
I would like to use in-app billing in my android application (instead of creation

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.