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 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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With