Tell me more ×
Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It's 100% free, no registration required.

I recently bought a Nexus 4 and I would like to transfer my photos of my previous device to it. My previous Android phone used the standard USB mass storage which gave 0 problems to copy back and forth stuff, but the Nexus 4, like many other modern Android phones I suppose, uses MTP instead, which has the interesting feature of refusing to copy the original dates/timestamps of the files, using instead the date at which the files are being copied.

This is obviously a huge bummer when it comes to photos; not only because one cannot check the original date at which the picture was taken while browsing on the phone, but also because they end up completely unsorted.

Is there a way to transfer photos to a Jelly Bean Android phone that doesn't support USB mass storage preserving the original timestamps?

Things I've tried so far:

  • Transferring via USB MTP
  • ADB push (both full folders and individual files)
  • Transferring via SSH (using SSHDroid + WinSCP)
  • Uploading and downloading from Dropbox
  • Transferring a ZIP file via MTP and uncompress the file on the phone
  • Transferring from the other phone via bluetooth
  • QuickPic "fix date" function
  • Local Sync
  • Photo Date Correction
  • FTPSyncX
  • Smoke signals
  • Yelling at the phone

None of them preserved the timestamp, and this is driving me insane.

(Also, I am not rooted yet, but if the only viable way requires root I would welcome that answer as well.)

share|improve this question
Does Android support untaring .tar files? If so, maybe you could copy a .tar file of the pictures. I don't know if the untaring would change the timestamp of the individual files or not. – Chance Dec 21 '12 at 22:46
@Chance tried that before but didn't help either; the issue is nothing has privileges to write the timestamp by default, so there's nothing one can do but rooting right now. – Mahn Dec 22 '12 at 1:19
Also, to everyone who chimed in in this question: Thanks. The way SE sites work I can only accept one answer, but every answer here helped in some or other way. – Mahn Dec 22 '12 at 1:21

5 Answers

up vote 6 down vote accepted

You can't, this is a current permission problem (bugreport here) of Android 4.0+'s /sdcard folder if it's not using FAT32 (but FUSE).

Reason: There's a transition away from FAT32 to unified user storage for both apps and media data (using ext4) on a single file system.

We got tired of seeing OEMs include many GB of internal storage for music, while users were still running out of space for apps and data. This approach lets us merge everything on one volume, which is way better.

-- Dan Morrill, Android engineer at Google

The old FAT32 properties are emulated using a FUSE layer to be compatible with existing apps. Also: /data/ and /sdcard on Google devices starting with the Nexus 7 use a single partition only (/data/media represents the "sdcard" content and is exposed using the FUSE layer to apps).

Here's CyanogenMod's implementation of the FUSE driver if you're interested in seeing the source. Looks like setting timestamp attributes is implemented, though.

EDIT: It only works with root.

Exact reason: All files are owned by root.sdcard_rw (see here).

A caller withouth uid=0 can't call the utimensat() syscall, it fails in the VFS layer already (EPERM) for timestamps other than current:

  1. the caller's effective user ID must match the owner of the file; or
  2. the caller must have appropriate privileges.

To make any change other than setting both timestamps to the current
time (i.e., times is not NULL, and both tv_nsec fields are not
UTIME_NOW and both tv_nsec fields are not UTIME_OMIT), either condition
2 or 3 above must apply.

share|improve this answer
Thanks for the info, let's hope this is something google can and would be willing to address, because as far as I can tell the problem is not the fuse layer or the mtp protocol, but the strict privileges that were set there, which by the way appear to be pretty recent (4.2.1?) since the Photo Date Correction app posted below did seem to work with older, 4.0 fuse/mtp based devices such as the galaxy nexus. – Mahn Dec 22 '12 at 1:15
1  
Update for future readers: this remains unfixed in 4.2.2. – Mahn Feb 20 at 12:24

This is a question which really trouble me a lot when come across with devices which only have MTP but not the Mass storage mode. I also have concerns about it with exactly the same reasons with Mahn.

After some testing, I have find a temp solution which maybe able to preserve the timestamp.

It makes use of the excternal sdcard / OTG card reader and also the cp command with -a the timestamp will be able to preserve. But the requirement is the phone need to be rooted.

  1. First copy the data to SDcard.
  2. Read it with memory card slot / OTG card reader
  3. use adb shell and acquire root permission (su)
  4. cp -a * the data from card to internal memory.
share|improve this answer

I have the exact same issue. It seems that it's being blocked by fuse on the Nexus 4 running Stock JellyBean 4.2.1.

SYMLINKS:
/sdcard -> /storage/emulated/legacy
/storage/emulated/legacy -> /mnt/shell/emulated/0

MOUNT POINT:
/mnt/shell /dev/fuse /mnt/shell/emulated fuse \
    rw,nosuid,nodev,relatime,user_id=****,group_id=****,default_permissions,allow_other 0 0

That info was taken via an adb shell session; I presume that fuse will be in the mix for all app-level accounts.

TL;DR From the looks of it, it can't be done without rooting the phone.

share|improve this answer
1  
My "solution" for the time being is to upload pictures from past phones one at a time in chronological order, with pauses in-between, in a different directory. Here's the Linux shell script I'm using: [old_pictures]$ for f in $(ls -1 * | sort -t _ -k 2); do adb push $f /storage/sdcard0/DCIM/Past/; sleep 3; done; If you go this route, do a test upload first to be sure you're satisfied. Also, disable Google+ Instant Upload while you're at it so you don't get "double uploads". – Turtle Dec 21 '12 at 0:53
Thanks, that helps; as your for script: both mtp via windows and adb push drop the connection for me after the first thousand files or so in my case, plus some files randomly end up corrupted, are you seeing the same? basically as this issue describes here: code.google.com/p/android/issues/detail?id=35185 (perhaps I should make a separate question, since this is not directly related with the timestamps themselves. Gotta love mtp though) – Mahn Dec 22 '12 at 1:02

Use a synchronization tool like e.g. FolderSync, which should take care for timestamps accordingly. Synchronization tools should be specialized in handling all aspects of really maintaining synchronous copies -- including time stamps, of course.

share|improve this answer
I tried a couple of sync tools, but none synced the timestamp, because I guess there is some sort of protection. Thanks for the answer though. – Mahn Dec 18 '12 at 19:08
Did you try FTPSyncX Trial? Not the most sophisticated look maybe (the dev is no designer). But I use the Pro for about a year already, and it syncs timestamps fine via SFTP/SSH (the only protocol I use -- the app can handle more). – Izzy Dec 18 '12 at 19:36
I'll check it, but considering SSHDroid didn't work for me I guess I won't get the timestamps with it either. – Mahn Dec 18 '12 at 20:51
I almost bet it will. I still remember how hard that part was for the dev -- we sat hours on Skype discussing the issue :) There was that ugly time problem on Windows, which sometimes reported things wrongly... Oh, getting OT :) Simply try it, cannot hurt, right? And let us know how it worked out... – Izzy Dec 18 '12 at 21:12
Nothing. FTPSyncX Trial as a client on the phone, freeSSHd as a server on my laptop, I'm able to connect and sync files via STP/SSH, but the timestamp of pictures transferred to the phone is still getting overwritten to the current date. – Mahn Dec 20 '12 at 9:33
show 3 more comments

Check the EXIF data and see if there's a timestamp there.

If there is, Photo Date Correction will allow you to overwrite the botched file timestamp with the EXIF one, giving you back your proper sorting.

share|improve this answer
Nothing. The EXIF data is there, and the app reported to successfully have changed the timestamps when I used it, but they stayed the same; I rebooted and deleted the cache of the gallery aswell, but that didn't help. Does the app require root? It seems as if there were some sort of write protection on the timestamps that nothing is able to overcome. – Mahn Dec 18 '12 at 19:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.