Ruwan Dissanayaka
Ruwan Dissanayaka

Reputation: 315

android replace drawable image programmatically

I have 10 images in drawable directory in my android project and I'm using those images in a gallery. I want to replace those 10 images programatically upon user request to download new images from the web.

Is this possible to replace the images in drawable of my App with downloaded images?

Thanks in advance

Upvotes: 0

Views: 1630

Answers (3)

No, this is impossible act. You cant manipulate any resource of APK(read-only).

You can store your image either in your Phone memory(Internal or External) or You can just create a Drawable(cache) at Runtime and flushed it.

You having directory called /data/data/package_name this folder will gets delete once you uninstall your Application and for other directory you have to delete manually.

Upvotes: 1

hasanghaforian
hasanghaforian

Reputation: 14022

You can not change resources of your App programmatically(as @hotveryspicy says),but you can create specific directory for your App(either private directory for your App or public) and download images to it.When your App wants to show images it has to check if there exists images in that directoy,display images from it,else display images from it's resources.

Upvotes: 0

nandeesh
nandeesh

Reputation: 24820

This is not possible. You will have to download and store it on disk. Either in internal memory or External memory.

Upvotes: 1

Related Questions