How to download a image to a drawable folder from a url? - android

I would like to add a image to a xml image view, and needs to be updated on timely basis.Whether is there a possibilty of updating directly to the drawables or how to do it from device memory i.e. downloading & calling from internal memory to the xml imageview.Kindly help me with an example or a snippet.Thank you.

Not possible. You will have to save image either to the SD CARD or the
data/data/package folder. You can not write/save image in drawable/res. Sorry.

You cannot update drawable folder.Only thing you can do is save the image in sdcard or in application memory ie /data/data//image.png.To set the image dynamically you can get reference of your image in your activity using findviewbyid and then set its image wherever required.

Research a bit before you ask a question...
During runtime you do not have access to your projects folders, as they are compiled to .apk file and that file runs on the device, now how on earth can you modify those folders while your app is running?
Try downloading it to your SD card or internal memory instead...

Related

Setting ImageView src from an image in Windows's drive

I have an image in my D drive (D:\...\Image.jpg) and I want to display it in my app, the thing is Im getting the image name from the database, and in my code Im doind something like:
image_view.setImageBitmap(BitmapFactory.decodeFile("D:\\Program Files\\Image_Folder\\"+item.Img_Name));
But Im getting an error saying there is no such file as (D:\Program Files...\Image.jpg), basically it's a No File Found Exception but Im sure the path is correct.
So I can't add it to drawable folder because I don't know wich image the user will select, and it would be silly to put all the images in the drawable folder to avoid this problem.
Any Ideas ?! Thank you.
You can't access images on another device like that. You need to either put all the images you need in the drawable folder, or set up a webserver on which you can get the images over a network connection.
You can get image only from device file directory, assets or drawable folders.
You can't access from your local drive it is supposed to be somewhere in your package or alternatively if only local directory is the option you can setup an ftp server through FileZilla (Server) and access your local drive through sharing.
Thanks

How to store the all jpg pictures that I've used in program

I want to implement an art game android application in Android Studio. But I'm confused about how to store the pictures? There will be 100 or more pictures of art works in game. The idea came to my mind is to minimize the sizes of pictures and adding them in drawable folder. Is there any efficient way to do that?
Thanks
First of all use TinyPng to compress your images without loosing ANY quality, I said ANY and I mean it.
and second don't put them in drawable because android will increase there sizes when you will generate signed APK, instead you should put them in raw directory which you can create in res directory, like res/raw.
Raw directory works same as drawable and any files in this directory gets resource Ids just like drawables so you can access files in it just like R.raw.yourimage.
I work on applications which includes hundreds of images and this is the best approach I have used.
Hope it helps.
If you are concerned with the space the 100 images takes up you could use a tool like photoshop or similar so compress your images to desired size (publish to web in photoshop).
Other than that I dont see why you shouldnt just save them in a drawable folder.

How to implement imageswitcher code in android application?

I want to get images name from database and images are stored in the resource folder
Could you show me how to do it.
I tried few methods but none works.
You cant do it, resource folder is read only folder, and the R.java also generated at compiled time, not in runtime. You can save the image in sd card or cache memory .

Where is the root path from the perspective of an Android app?

The page on Picasso shows an example usage of its library
Picasso.with(context).load(new File("/images/oprah_bees.gif")).into(imageView2);
I suppose images is not actually in the root folder of the device, maybe the assets folder of the app?
I suppose images is not actually in the root folder of the device
According to that File object, that is exactly where it is. This is... unrealistic.

get images from memory card and store in drawable folder

I made a application in which many images are shown,
all images are pre-stored in drawable folder of resources,
but if i want to add new picture then how can i do this,
it should read from memory card but only once, after that it automatically load.
If I understand correctly, you want to upload images yourself to the app instead of letting user use images or..?
If it's you, who should upload new images, you can download them to the app with a check if there are new ones.
If it's the user, you can check their gallery on the sd card, but unfortunatly I don't think it's possible to store these in the drawable folder.
You mean you want a dynamic drawable folder? You cannot do that since APK file is read only...
you cant do this, because it is an impossible act, Drawable folder is meant to make the Application Environment when it is deployed, it is a one way process. you can copy Drawble image to external path

Categories

Resources