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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:23:04+00:00 2026-05-30T22:23:04+00:00

I want to be able to load images dynamically from res/drawable. I don’t how

  • 0

I want to be able to load images dynamically from res/drawable. I don’t how many files there will be, but I do know they will be named by convention as “image_N”, where N is sequential integer. It is possible that new images will be uploaded while the app is running.

My code is basically

Resources rs = getResources();
String imgName = "android.resource://" + this.getPackageName() + "/drawable/image_" + i;
int imgID = rs.getIdentifier(imgName , null, getPackageName());

if (imgID != 0)
{
    Drawable d = rs.getDrawable(imgID);
    //etc.
}

but imgID being returned is always 0.

I also tried another approach

String imgName = "android.resource://" + this.getPackageName() + "/drawable/image_" + i;
b = BitmapFactory.decodeFile(imgName);
if (b != null)
//etc

But b is always null.

I know there are files in the folder with the right names because I put a few there. Not sure what I’m doing wrong. Any help would be greatly appreciated!

  • 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-30T22:23:05+00:00Added an answer on May 30, 2026 at 10:23 pm

    I think you’ve mistaken compiled resources with files inside folders. In Android, resources are static as far as I know. Once compiled you can’t add new resources by dropping files inside “drawable” folder, there would be no IDs for new files.
    You should use a folder in DATA or better ask Android API with getFilesDir() or something similar.

    For more info, take a look >>here

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

Sidebar

Related Questions

For performance I want to be able to load images in typo3temp/pics and uploads/pics/
I want to be able to load a serialized xml class to a Soap
in my js file i want to be able to load a splash screen
I'm writing a simple CMS. I want to be able to load a View,
In my android application, there are number of images in drawable folder. In my
I want a web page to display several random images on load. I've thought
I have some .png images and I want to be able to quickly: (a)
I upload images with a php script and I want to be able to
In a Image tag src = path, I want to dynamically load the image
I want to display images in WPF, but using an actual image, instead of

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.