Android: How to get a file's creation date?

后端 未结 6 1714
孤独总比滥情好
孤独总比滥情好 2020-11-28 05:38

This is my code:

File TempFiles = new File(Tempfilepath);
if (TempFiles.exists()) {
    String[] child = TempFiles.list();
    for (int i = 0; i < child.l         


        
6条回答
  •  自闭症患者
    2020-11-28 05:57

    There is an alternate way. When you open the file for the first time save the lastModified date, before you modify the folder.

    long createdDate =new File(filePath).lastModified();
    

    And then when you close the file do

    File file =new File(filePath);
    file.setLastModified(createdDate);
    

    If you have done this since the file was created, then you will have the createdDate as the lastModified date all the time.

提交回复
热议问题