W I Z A R D W I Z A R D - 1 month ago 9
Android Question

Display the Android application.apk creation date in Application

I am developing an android application, i want to display the Version of the

.apk
and date now i can able to display app version of the application using
PackageInfo
and now i want to display the date when app is created or
.apk
creation date.

Answer

Method which checks date of last modification of classes.dex, this means last time when your app's code was built:

 try{
 ApplicationInfo ai = getPackageManager().getApplicationInfo(getPackageName(), 0);
 ZipFile zf = new ZipFile(ai.sourceDir);
 ZipEntry ze = zf.getEntry("classes.dex");
 long time = ze.getTime();
 String s = SimpleDateFormat.getInstance().format(new java.util.Date(time));

 }catch(Exception e){
 }