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
Related
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 .
I'm building a travel infomation. My app has about 500 images in structure folder.
I don't know how to read/write by my application.
I usually read and write image by id through drawable. But put 500 image on drawable folder may be a wrong place.
what should I do? It would be awesome if someone had some example code.
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...
Hi all,
How can i replace the text or symbol from web service with local images in drawable folder.
I get a symbol and text from web service. I need to replace that symbol with my image that is saved in local drawable folder in the application.
Please suggest few ideas of how can i do that.
Thanks in advance.
You cannot change or add any drawables inside your drawable folder. These resources are compiled into an .apk file, and there is no way to change them at runtime. Only solution I see is to store downloaded images on SD card and fetch them when you need it. Hope this helps.
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