Is it possible to read and write to the gallery on Android?
I want to be able to get a list of all images in the gallery, and store those images onto a server. I also want to be able to download the images from the server and save them into the gallery. Is that possible?
I can’t seem to find the API for doing this, so it would be great if you could point me in the right direction! Thank you!
You can read from the gallery using the
ContentResolver.query()method. For example:This will give you a
Cursorto all photos in the database.IMAGES_PROJECTIONis aString[]of columns you are interested in getting values from. These columns are listed inImages.ImageColumns.To get the
Bitmapfor each image in the gallery, you need to get the_IDvalue for each row in the cursor, then call this:To write to the content database, you can use:
To insert a video is a bit more involved. If you need sample code for that, let me know and I can get that for you also.