Hey, I was having the same problem as you. I wanted to copy and asset over only if it was newer. So I made the sharedPreferences store the last version installed, and used that to compare dates:
I add an entry to the strings.xml file to hold the application version:
<string name="version">0.3</string>
Then I put an if clause on the onCreate method of the main class:
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
if( Float.parseFloat(getString(R.string.version)) > prefs.getFloat("LastInstalledVersion", (float) 0.0 ) ) {
copyfiles();
}
And I add the new version string to the sharedPreferences on the onPause method, that way it will be added for sure before the onCreate is called again:
SharedPreferences prefs= PreferenceManager.getDefaultSharedPreferences(this);
SharedPreferences.Editor editor = prefs.edit();
editor.putFloat("LastInstalledVersion", Float.parseFloat(getString(R.string.version)) );
editor.commit();
Probably simpler than using version names in the file itself.
Note that copyfiles will run the first time the application is opened, if you have version above 0.0, and will only run again if you increase the version string in later versions.
Keep in mind this example only works if you have a single file to compare, or don't care about individual file versions. Otherwise you could use several different strings to store file versions.