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 7978807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T09:35:27+00:00 2026-06-04T09:35:27+00:00

I am creating an Android board game similar to, for example, Bubble Pop where

  • 0

I am creating an Android board game similar to, for example, Bubble Pop where I need to use several bitmaps multiple times.

I have a list of Stones (10×10), where each Stone is an object which holds its bitmap and some other values. Lot of bitmaps (stone colors) are same.

Right now i am using something like this for every Stone in the list:

public class Stone extends Point{

  private Bitmap mImg;

  public Stone (int x, int y, Resources res, Stones mStone) {
    ...
    mImg = BitmapFactory.decodeResource(mRes, mStone.getId());
  }

  protected void changeColor(Stones newD){
      mStone = newD;
      mImg = BitmapFactory.decodeResource(mRes, mStone.getId());
    }
  }

I found several similar questions, but it is all about big bitmaps. Also i found some Android documentation about caching images, but i am not sure if it solves my problem and how to share this cache between all my stones.

What is the best practice, to achive good performance and avoid OutofMemoryError?

  • 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-04T09:35:29+00:00Added an answer on June 4, 2026 at 9:35 am

    You probably don’t need cache. Since you should have a limited number of stone colors (thus bitmaps) you can consider holding those graphic assets in one single class (probably static global class or through singleton pattern.

    In your Stone class, you just need to hold the stone’s color Id and get the drawable from your assets class. (you can save bitmap, but drawable is much more efficient and you may easily change it to allow some animation later)

    For example:

    // Singleton - look at the link for the suggested pattern
    public class GraphicAssets {
        private Context mContext;
        private Hashtable<Integer, Drawable> assets;
    
        public Drawable getStone(int id){
            if (assets.containsKey(id)) return assets.get(id);
    
            // Create stone if not already load - lazy loading, you may load everything in constructor
            Drawable d = new BitmapDrawable(BitmapFactory.decodeResource(mContext.getResources(), id));
            assets.put(id, d);
            return d;
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating an Android game and I encountered a problem. I have 2 threads:
I am creating a android app using LunarLander as a example. Now I need
I'm creating an android app that will have multiple pages with the same layout,
I'm creating an Android application (a game, to be more precise) and using AndEngine
I am creating an Android app (API 8) that need to receive a lot
I am creating an android game where enemies are generated randomly and there can
I am creating an Android application which will have some embedded music inside of
I have recently started learning java for creating android apps. I have spent hours
I'm am creating an Android application, but in order to have one of the
I developed a board game app (for android/iphone) and added a multiplayer component 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.