Bizarre question: is it possible to get the last modified date of a file in the assets folder, or would that be pointless and impossible?
I ask because I’m copying a read-only database out of there into the data folder on application start up, but would rather only perform the copy if the existing file is older than the one stored in the assets folder (or if the file doesn’t exist).
If that’s not possible, anyone know of a better convention? I can post that in a separate question if needed. TIA!
How big/complex is the database? You might find it’s easier and more flexible to use an instance of
SQLiteOpenHelperto handle this since with one call togetReadableDatabase(), it will create if necessary the database, and call youronUpgradeto upgrade the database for you.All you have to do is provide an
onCreate()to create the database, provideonUpgrade()to upgrade, and increment the database version (inonUpgrade()) when it changes and Android will handle creating and upgrading the database for you.Alternatively, (and I haven’t tried this), it looks like
AssetManager.list()can provide you a list of paths to your assets, next, useFile (String path)to get a File object for the database, and finallyFile.lastModified()to get the modified date.