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

  • SEARCH
  • Home
  • 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 7862821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:17:34+00:00 2026-06-02T23:17:34+00:00

In my application there is a set amount of images that need cached. It

  • 0

In my application there is a set amount of images that need cached. It is about 12 – 15 images I will need cached tops. What I have done is store the image in a file in a directory on the device like this.

    FileOutputStream o = new FileOutputStream(getFilesDir().getAbsolutePath()
                + "/background.txt");
        Bitmap b = getBitmapFromURL("http://10.84.4.2:8083/images/General/background.png");
        b.compress(Bitmap.CompressFormat.PNG, 90, o);

Then just reload the image when I need it like this

BitmapDrawable bg  = new BitmapDrawable(BitmapFactory.decodeFile(c
                .getFilesDir().getAbsolutePath() + "/background.txt"));

I download the images all at once using Asynch Task like this

public class DownloadImagesTask extends AsyncTask<String, String, Bitmap>
{

    Bitmap bmp;
    String name;

    @Override
    protected Bitmap doInBackground(String... urls)
    {
        name = urls[1];
        return download_Image(urls[0]);
    }

    @Override
    protected void onPostExecute(Bitmap result)
    {
        try
        {

            FileOutputStream o = new FileOutputStream(getFilesDir()
                    .getAbsolutePath() + name);
            result.compress(Bitmap.CompressFormat.PNG, 90, o);
        } catch (Exception e)
        {
            e.printStackTrace();
        }

    }

    private Bitmap download_Image(String url)
    {
        return bmp = getBitmapFromURL(url);

    }

}

My question is, is this a bad way of doing this? I tried finding good tutorials about caching online, but found it difficult to find a full tutorial that actually explained it properly. The method I am using seems quite simple, but not sure if it is recommended.

Would be grateful if anyone could tell me what are the pros and cons of doing it my way, and should I consider changing to another method.

Thanks

  • 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-06-02T23:17:35+00:00Added an answer on June 2, 2026 at 11:17 pm

    try using FedorVlasov’s image loader from the lazyadapter project

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

Sidebar

Related Questions

I have an application that does a large amount of number crunching on an
I'm developing an application that will need to communicate with itself running on different
I want to build an application that can set up a set amount of
In My Application there is two EditText and one TextView. I have set the
We have a MFC 8 application compiled with /CLR that contains a larger amount
I have an application that performs a very sequential set of discrete tasks. My
Is there a way to set up an appengine web application to deploy on
Is there a way to set a .NET application's TimeZone to a value other
I have an application which is using a set of three combo boxes. I
Are there any open source applications that provide a set of features similar to

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.