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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:30:56+00:00 2026-05-28T08:30:56+00:00

I am working on an Android application where I deliver some built-in images and

  • 0

I am working on an Android application where I deliver some built-in images and give the user the option to download some more from the web to use in the application. At some point in my app, I look at an ImageView in my layout and want to determine if the Drawable inside is an in-built resource or an image I have downloaded from the web to the SD Card.

Is there any way to extract the URI of the Drawable used in the ImageView? This way I would be able to see if it is a resource or a downloaded file.

Here is my code so far:

ImageView view = (ImageView) layout.findViewById(R.id.content_img);
Drawable image = view.getDrawable();

UPDATE:
Using Barry Fruitman’s suggestion from below, I stored the URI of the image directly inside my custom ImageView for later use. Here is what my implementation looks like:

public class MemoryImageView extends ImageView {
private String storedUri = null;

public MemoryImageView(Context context, String Uri) {
    super(context);
}

public MemoryImageView(Context context, AttributeSet attrs) {
    super(context, attrs);
}

public MemoryImageView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
}

public String getStoredUri() {
    return storedUri;
}

public void setStoredUri(String storedUri) {
    this.storedUri = storedUri;
}

}

And usage looks like this:

MemoryImageView view = (MemoryImageView) layout.findViewById(R.id.content_img);
String img = view.getStoredUri();
if(img.startsWith("android.resource")) {
    //in-built resource
} else {
    //downloaded image
}
  • 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-28T08:30:57+00:00Added an answer on May 28, 2026 at 8:30 am

    No. Once you create the Drawable that information is lost. What I suggest you do is subclass the ImageView and add extra member(s) to keep track of whatever you want.

    Replace:

    <ImageView />
    

    with

    <com.mypackage.MyImageView />
    

    And create:

    class MyImageView extends ImageView {
        protected final int LOCAL_IMAGE = 1;
        protected final int REMOTE_IMAGE = 2;
        protected int imageType;
    }
    

    MyImageView will behave exactly like an ImageView, but with that extra member that you can read and write anywhere you want. You will probably also have to override the ImageView contructor(s) with constructors that just call super().

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

Sidebar

Related Questions

I'm trying to connecting SQL Azure from my android application. The code is working
I'm working on an Android application where I need to use the antenna of
I am working on a android application which read the sms from content provider.
Hi am working on an android application. And am using a listview in some
I'm working on Android application which is taking content from internet using JSON, I
I am working on an android application that determines user location in osm maps.
I am working on an Android application that parses one or more XML feeds
I'm working on an Android application. Our problems manifest when the user runs our
I am working on an Android application that requires a user to login before
I'm working on an Android Application for AutiPlan, which is a web-based planner tool

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.