I'm trying to create a small puzzle game. My problem is to set the folder where the app reads pictures. Is possible to create in the drawable folder another folder called "images", and insert in this folder the pictures that the app reads ?
I'm using:
((SelectImagePreference) findPreference(IMAGE_SOURCE)).setCustomLocation(data.getData());
Use assets folder http://www.wiseandroid.com/post/2010/06/14/Android-Beginners-Intro-to-Resources-and-Assets.aspx
Related
I have some problems while loading the file from the asset folder.
I wrote a code to load a txt file into a textview and everything works good.
If I try to put some order inside my txt file. I decided to put those files in subfolders in alphabetic order, because I have 800 text files. In this way my code is wrong. Is there a method to maintain the subfolders and load the file whitout specify where they are??
Thanks a lot
I want to add my image in Drawable s All files according to its size with single image
how it can perform .
Actually I retrieve images from DB Server..While no need to define Server logic in your Answer
You can't add resources in your app at runtime. So you will not be able to add image in your drawables folder.
However you can store in it in a file in your app directory using Context.openFileOutput.
I'm looking to have a user select an image from the gallery, and have this file saved as a permanent drawable resource when they open the app at a later time. Is this possible?
I mean as an object in the actual drawable folder.
No, it's not possible. "The drawable folder" doesn't exist as a file system folder at runtime - it's part of your (read-only) binary .apk file.
You could instead save the image at internal folder and/or define a preference string.
Check this old answer https://stackoverflow.com/a/3374138/4618976
I am working on an ANDROID project where I have a lot of images and I want to organize it.
So I need to create folder inside the drawable folder.
But I don't know how to reference it in my program.
For eg: I have an image named "image.png" and I want to place it in drawable/myicons/image.png
or anywhere inside the res folder.
This is duplicate question
You can not create folder inside drawable
the resources mechanism doesn't support subfolders in the drawable directory
However you can use the assets folder and have sub directories in there and load images that way.
I am new to Android development. To implement a photo gallery app, tutorial said to add images to res/drawable and access them via R.drawable.image1 .. etc. But there is no drawable folder default in eclipse, then I created a one and add images. But cannot access images, there is no option in R.drawable. as "image1"
Any idea ?
you should create "drawable" folder under "res", and you'd best place png image files in that folder. When accessing these image files programmingly.set an image for an ImageView for example:
Drawable imgDrawable=getResources().getDrawable(R.drawable.yourImageFileName));
imgView.setImageDrawable(imgDrawable);
Sometimes the drawable folder is not created by default Instead it will have "drawable-hdpi","drawable-mdpi" and "drawable-ldpi".These folders are for placing images for various screen densities to support different resolutions.Your "drawable folder" is for baseline medium density.
In your case create a folder named "drawable" under "res" and place your image inside that folder and you will be able to access it using R.id.imagename .Try refreshing the project and check whether you have created the drawable folder under the res folder.Also check the case of the folder name that you have created.
I faced same problem , but when i added those images again in jpg format it worked.
Might work for you too.
My System was based on windows 10 & was using android studio 4