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

2

8

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.

Springbok answered 22/7, 2013 at 11:38 Comment(3)
I would try this other method of alerting MediaScanner: https://mcmap.net/q/1470458/-android-music-player-not-reindexing-after-song-additionAttested
Tried that method, but I get the same results.Springbok
Had the same problem but for just one folder on my device, created with ES explorer. The fix for me was to rename the folder on the phone, which made the new name AND the old name appear in windows explorer. whatever this is, it now shows the files.Hereinafter
G
5

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.

Gagger answered 22/7, 2013 at 11:59 Comment(2)
Tried that fix (unplugging and plugging USB), but it doesn't help. I don't think I'm violating any of the three items that Wikipedia mentions. But I do agree that MTP has many drawbacks!Springbok
Yea, could be a separate issue. Just to be clear, the screenshots that were previously sized 0 kb went to their respective sizes after the unplug-replug hack. Screenshots taken while connected were still of 0 kb.Gagger
T
1

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.

Toms answered 8/10, 2015 at 2:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.