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.
This example demonstrates how do I convert Bitmap to drawable in android. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml.
To use an image resource, add your file to the res/drawable/ directory of your project. Once in your project, you can reference the image resource from your code or your XML layout. Either way, it's referred to using a resource ID, which is the file name without the file type extension. For example, refer to my_image.
To import image resources into your project, do the following: Drag and drop your images directly onto the Resource Manager window in Android Studio. Alternatively, you can click the plus icon (+), choose Import Drawables, as shown in figure 3, and then select the files and folders that you want to import.
In Android Studio inside the res folder, one can find the drawable folder, layout folder, mipmap folder, values folder, etc. Among them, the drawable folder contains the different types of images used for the development of the application.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With