How to add an image to the emulator gallery in android studio?

I am developing an image filter app. But can't really try it if i don't have any images.

I know that i can test it in the phone, but it's not the same, since I need the error messages and other stuff.

I just want to access an image from the AVD's gallery so that I can test my app. How can I add one?

I am using Android Studio. I saw some examples on how to do it in Eclipse, but i am not using that.

So, how can I add an image to the emulator image gallery?


Solution 1:

It's a very old question but I will answer this for future references.

To add any file to emulator just drag and drop the file.

The file will be copied to downloads folder of internal storage.

To access the file

Go to settings

Click On Storage & USB

Click On Internal Storage

Click On Explore (at the end)

and you got it in the downloads folder

now you will get notification to setup virtual SD card, follow the setup. after the successful setup you will be able to see pictures in gallery.

Solution 2:

I'd like to complement Mithilesh Izardar's answer:

Indeed the best approach is simply to "Drag and Drop", which afterwards you can find the files in the emulator at Settings → Storage → Internal Storage → Explore → Download (API 25). The problem for me was that after following these steps the pics weren't appearing neither in the "Gallery" nor in the "Downloads" (by simply clicking the "Downloads" icon).

The reason for this is because by default everything in the emulator has no permissions...so all you gotta do is give the "Gallery" storage permission: Settings → Apps → Gallery → Permissions (API 25)

Ps: If you just copied the pictures, the new ones won't show up right away. You should either restart the emulator, or remount the sdcard (at Settings → Storage unmount the sdcard by clicking the eject icon then remount it)

Solution 3:

How to import images into the gallery of an Android Virtual Device using Android Studio: I'm using Android Studio 1.4.1 and a API 15 virtual device.

Warning: This is manual intensive so it is not a good solution for a large number of images.

  1. Create a virtual device using Android's Device Manager (AVD), Menu /Tools/Android/AVD Manager.
  2. Start this virtual device.
  3. Start the Android Device monitor, Menu */Tools/Android/Android Device Monitor. In the Devices tab (upper left) you should see your device. It should be Online (see this screenshot)
  4. On the right window is the File Explorer. Go there and select the /mnt/sdcard/Pictures directory. It should be highlighted (see this screenshot)
  5. Add jpegs to this directory by clicking on the Push a file onto the device icon (the little phone icon I highlighted in the above screenshot. You can add only one photo at a time, dadburnit.
  6. Go to your device and run the Dev Tools app.
  7. Scroll down and select Media Provider.
  8. Click on the Scan SD Card button. This should copy the images you added in step 5 to the gallery. Go to the gallery and look, they should be there.

Solution 4:

After trying to add an image via the Device Monitor or via drop, I could find it when exploring, but it was still not shown in the Gallery.

For me, it helped to eject the (virtual) sdcard from Settings > Storage & USB and reinserting it.