根据其在android中的创建日期对文件进行排序 [英] sorting files based on its creation date in android
本文介绍了根据其在android中的创建日期对文件进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想要基于创建日期的文件列表. 当我更新任何if图像并尝试检索所有图像时,则随机更改顺序.
I want list of file based on my creation date. When i updating any if images and trying to retrive all images,then orders are changed randomly.
这是我的代码,
File[] files = parentDir.listFiles();
for (File file : files) {
// I am getting files here
}
任何帮助..
推荐答案
我想要基于创建日期的文件列表.
I want list of file based on my creation date.
如前两个答案所指出的,您可以根据修改日期对文件进行排序:
As the two previous answers pointed out, you can sort the files according to the modification date:
file.lastModified()
但是修改日期已更新,例如在重命名文件的瞬间.因此,这将无法代表创建日期.
But the modification date is updated e.g. in the instant of renaming a file. So, this won't work to represent the creation date.
不幸的是,创建日期不可用,因此您需要重新考虑基本策略:
Unfortunately, the creation date is not available, thus you need to rethink your basic strategy:
这篇关于根据其在android中的创建日期对文件进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文