简体   繁体   中英

how to get the file properties in assets folder on android?

I want to get the file properties in assets folder on android,But it is unlike general operation use some kinds of methods to get,anybody can help me to get the file properties such as modified date. My assets file has a "ok.txt",please do me a help?

If I understand you correctly, I think this blog post will answer your question, with code showing example of using InputStream:

http://myossdevblog.blogspot.com/2010/02/reading-properties-files-on-android.html

You can get last modified date with lastModified() .

File file = new File(<file path>);
long lastModified = file.lastModified();

But lastModified() returns unix time. You can convert it with format.

Date date = new Date(lastModified);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SS");
String formattedDate = sdf.format(date);

看一下File类的文档,有很多方法可以获取有关文件的任何信息。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM