且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

是否有可能获得最后修改日期从资产的文件?

更新时间:2023-01-29 19:42:12

如何大/复杂的是数据库?您可能会发现它更容易和更灵活地使用 SQLiteOpenHelper 同一个呼叫处理这一点,因为到 getReadableDatabase() ,它会在必要的数据库中创建,并调用你的 onUpgrade 升级数据库给你。

How big/complex is the database? You might find it's easier and more flexible to use an instance of SQLiteOpenHelper to handle this since with one call to getReadableDatabase(), it will create if necessary the database, and call your onUpgrade to upgrade the database for you.

所有你需要做的是提供一个 的onCreate() 来创建数据库,提供 onUpgrade() 进行升级,并增加数据库版本(在 onUpgrade() ),当它改变和Android将负责创建和升级数据库给你。

All you have to do is provide an onCreate() to create the database, provide onUpgrade() to upgrade, and increment the database version (in onUpgrade()) when it changes and Android will handle creating and upgrading the database for you.

另外,(我没有试过),它看起来像 AssetManager.list() 可以为您提供的路径列表,以你的资产,然后,使用的 文件(字符串路径) 以获取数据库中的文件对象,最后的 File.lastModified() 得到修改日期。

Alternatively, (and I haven't tried this), it looks like AssetManager.list() can provide you a list of paths to your assets, next, use File (String path) to get a File object for the database, and finally File.lastModified() to get the modified date.