Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Files showing as empty on PC but non-empty on Smartphone [closed]

I'm having a weird problem with my Samsung Galaxy Nexus, where files created and written to in my application are displaying fine when accessed on the phone itself (via ES File Explorer), but when I try to view the same files on my PC (with phone connected via USB), they show up as having 0 bytes (and empty when opened).

These should be normal text files, which I am creating using new File(dir, filename) and writing to using the write method of PrintWriter. I'm also adding the new files to the content database using MediaScannerConnection.scanFile.

I've used basically the same code in previous applications (>6 months ago) without any issues, so I'm really confused as to why it's not working now. Has anyone had similar problems?

UPDATE:

Still trouble-shooting this...two more observations have me utterly confused:

  1. I tried accessing the same files on another PC, and they worked fine. This had me thinking it could be some driver issue, but that would still be odd because I haven't changed the driver at all (I never experienced this issue earlier).

  2. I tried creating files using a different application that I previously created. It uses basically the same FileIO class for file creation, etc. No such issues experienced with this application.

like image 311
robguinness Avatar asked Jul 22 '13 11:07

robguinness


2 Answers

I faced the same issue. This has to do with how MTP (Media Transfer Protocol) is defined.

MTP has a few drawbacks. Wikipedia lists them as :

  1. When opening a file, the user must wait till the file has copied to the PC before it can be viewed. (Note: The file remains on the PC hard drive after viewing and the device is removed)
  2. No creation of files on the device from the PC, files must be created on the PC and copied over.
  3. No editing of files on the device, files must be copied off the device before edits can be saved and file copied back.

In my case, screen caps I took while the phone was connected through usb came out to be 0 kb in size(on PC). But, unplugging and plugging the usb solved this.

like image 172
Vikram Avatar answered Oct 27 '22 21:10

Vikram


I had the same problem, when I plugged my phone in it said the folder was empty, however when I unlocked my phone all the files appeared on my computer. I have fairly stringent security settings, but it's worth a try.

like image 27
Sarah Avatar answered Oct 27 '22 21:10

Sarah