0

Is it possible to get the path of an image in string form in android like

res/drawable/image.png

Or is their any other way for getting string path of an image that is placed in drawable.

1
  • 1
    why you want that path in string ? Commented Feb 16, 2012 at 7:33

2 Answers 2

2

No, it is not.

Drawable drawable = this.getResources().getDrawable(R.drawable.ic_launcher);

e.g. will give you the default launcher icon. It is not possible to get the exact path for an image , that is stored in drawable.

Why not? When you compile your app to an *.apk file, all resources (ok, except from them in /raw) are compiled as well. You can only acces them, using their R. id.

Solution? Not really, you could copy them to a location on the sd card for example. Now you know the location :)

Sign up to request clarification or add additional context in comments.

Comments

2

its not possible to get path of drawable image directly , but you can get this by storing it in internal memory or sdcard of device.For this i have written blog.. check out the link here

i am sure it will help you.

2 Comments

nope - for copying the resources to an external storage you first must know the path to put them in. this creates a circular problem - you must know the path to put a resource on SD in order to know the path. the whole process is pointless. also your "solution" does not cover the case of devices with no SD storage or non-removable storage.
I am saying that if you have any images in drawable and you want to use its path in code , you want be able to do that. so for that you just copy image at particular location in internal storage if you dont have sd card. i am not forcefully saying you to use SD card.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.