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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T10:16:52+00:00 2026-05-21T10:16:52+00:00

I want to create a utility class that loads images contained in the assets/

  • 0

I want to create a utility class that loads images contained in the assets/ file structure. It would be tiresome to require all calls to it, or any other utility class calling it, to pass along the Context all the way from the UI.

Would it be possible to just pass it down once, and store it (as long as the utility class is static or a singleton)? Or would that have devastating consequences memory wise?

Also, so no one asks, I’m using the assets/ folder instead of res/ because I want sub-folders, and to access images by name dynamically, which I can’t do using resources to my knowledge. For example, I want my sprite object to load all images in the specific sprite’s folder, rather than hard coding R.drawable.sprite1front, R.drawable.sprite1leftside, etc.

*edit – Copying the AssetManager would also be fine, if that can be done.

  • 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-21T10:16:53+00:00Added an answer on May 21, 2026 at 10:16 am

    You can use a singleton or a static class for your utility class, but you should initialize it with a reference to an Application object, not an Activity. (Keeping a reference to an Activity is a good way to leak memory.) The best way might be to subclass Application and use that as your utility class. You’ll have to declare your Application class in the manifest.

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

Sidebar

Related Questions

I want to create simple utility class that has no visual elements and create
I am trying to create a utility class that accepts any type of POJO,
I want to create a utility class with common functions I need. So they
I had a requirement to create a small file utility class to run off
I want create wordpress website into which I want create user management... That means
i want create a custom json data from the mssql 2008 results so that
i want create image animation , i have 50 images with png format now
I want to create a new field (or two) in my table that is
I have implemented some utility classes in Flex that I want to use in
I want to create my own user configuration utility targetted for WinCE6 in C++.

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.