0

Why doesn't Android keep track of the created and last accessed times as well as the last modified time for files in the file-system?

3

It doesn't store creation time because UNIX filesystems (generally speaking) simply don't store this anywhere, and Android doesn't seem to be any different. This Stack Overflow question has some discussion about this fact (you can ignore the fact that it's talking about Python - the answers are still relevant), and the man page for stat describes what times are typically stored in the data structure.

As for the last accessed times...well it does keep track. Try ls -l in any directory you have proper permissions for:

$ cd /sdcard/
cd /sdcard/
$ ls -l
ls -l
drwxrwxr-x system   sdcard_rw          2011-04-27 14:31 LOST.DIR
drwxrwxr-x system   sdcard_rw          2011-04-27 14:31 DCIM
drwxrwxr-x system   sdcard_rw          2011-04-27 14:31 Android
drwxrwxr-x system   sdcard_rw          2011-04-27 16:14 glogs
-rwxrwxr-x system   sdcard_rw    49152 2011-05-27 16:04 AndroidBytes.txt
drwxrwxr-x system   sdcard_rw          2011-06-28 16:28 vim
-rwxrwxr-x system   sdcard_rw        0 2011-09-11 16:48 su-2.3.1-bin-signed.zip
$

If you have busybox you can also use the stat command for more detailed info. It also lets you use some additional ls flags like -u, -c and -t (see man ls if you're not familiar with it). Here's a sample from stat:

# stat databases
stat databases
  File: "databases"
  Size: 2048            Blocks: 4          IO Block: 4096   directory
Device: 1f06h/7942d     Inode: 454         Links: 1
Access: (0771/drwxrwx--x)  Uid: (10079/  app_79)   Gid: (10079/  app_79)
Access: 2011-09-29 09:07:44.000000000
Modify: 2011-09-29 09:07:44.000000000
Change: 2011-09-29 09:07:44.000000000
#
| improve this answer | |
  • When using stat on a file on the sdcard one gets 'Uid: (0/root)' . – IHeartAndroid Mar 23 '14 at 18:29
  • "It doesn't store creation time because UNIX filesystems (generally speaking) simply don't store this anywhere" -- what??? UNIX systems DO store creation time! You can access them with the -c option to ls. – Tomas Jun 29 '19 at 8:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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