Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"No media found". How to insert image in android

Tags:

android

I am new to android programming so I will be really grateful if someone helps me.

I am trying to implement steganography in android but my problem is I don't know how to insert images in android. Because of which I am getting "No media found". Please help me with this.

I tried

c:> adb push c:\image1.png /sdcard/image1.png

But I get this in the Command Prompt.

failed to copy 'c:\image1.png' to 'sdcard/image1.png' : Read-only file system

like image 288
Jannat Arora Avatar asked Dec 03 '22 02:12

Jannat Arora


2 Answers

I had the same problem, so in case anyone lands on this page here is how I solved it

  1. When creating the emulator device (I use IntelliJ IDEA) - do not forget to move the radio button on SDCard option to the Size option, and specify the needed size, this way a new SDCard will be created and mounted to the emulator. In eclipse there are some command line parameters you can pass (or something else, I am not sure, since I read it only on the stackoverflow).
  2. After that I stopped receiving the "Read-only file system" error, but I tried and tried and tried copying the files to the sdcard using: adb push image.jpg /sdcard/image.jpg or adb push image.jpg /mnt/sdcard/image.jpg but was receiving "No media found" error in my app or when I went to the gallery. So I went to Dev Tools on the emulator applications, then to the Media Scanner. It quickly scanned the sdcard, and boom - I finally got to see my images.

Hope this helps :)

like image 177
ksu Avatar answered Jan 03 '23 06:01

ksu


The correct directory for my emulator is mnt/sdcard. This works for me:

adb push README mnt/sdcard

Also note that you can explore directories using adb shell ls <path>, which might have tipped you off to the right path.

Edit - apparently sdcard is a symlink to mnt/sdcard and works for me as well. Using a file named image1.png is also working. Maybe there is a problematic file already located at that location for you?

Edit 2 - I think you also need to have the USB mounting option turned off when you use adb to push files. It sounds like you have this on given your comment about the gallery not finding your media.

like image 43
Matthew Willis Avatar answered Jan 03 '23 08:01

Matthew Willis