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

前端 未结 3 1130
难免孤独
难免孤独 2021-01-14 03:40

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 propert

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-14 03:44

    You can get last modified date with lastModified().

    File file = new File();
    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);
    

提交回复
热议问题