![](/img/trans.png)
[英]How to get the android Path string to a file on Assets folder?
[英]how to get the file properties in assets folder on android?
我想在android上的assets文件夾中獲取文件屬性,但它不像一般操作使用某種方法獲取,任何人都可以幫我獲取文件屬性,如修改日期。 我的資產文件有一個“ok.txt”,請幫我一個忙嗎?
如果我理解正確,我認為這篇博文將回答您的問題,代碼顯示使用InputStream的示例:
http://myossdevblog.blogspot.com/2010/02/reading-properties-files-on-android.html
您可以使用lastModified()
獲取上次修改日期。
File file = new File(<file path>);
long lastModified = file.lastModified();
但是lastModified()
返回unix時間。 您可以使用格式轉換它。
Date date = new Date(lastModified);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SS");
String formattedDate = sdf.format(date);
看一下File類的文檔,有很多方法可以獲取有關文件的任何信息。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.