Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><a href="http://developer.android.com/reference/android/content/pm/PackageInfo.html#firstInstallTime" rel="noreferrer">PackageInfo.firstInstallTime</a> gives you the install time in <em>"Unix time"</em> (the time in milliseconds since <em>"the epoch"</em>, i.e. <em>January 1, 1970 00:00:00 UTC</em>). You may use <a href="http://docs.oracle.com/javase/6/docs/api/java/util/Date.html" rel="noreferrer">java.util.Date</a> or <a href="http://docs.oracle.com/javase/7/docs/api/java/text/DateFormat.html" rel="noreferrer">java.text.DateFormat</a> in order to format this time.</p> <pre><code>private static final String TAG = "MyActivity"; ... packageName = ... ... try { PackageInfo packageInfo = pm.getPackageInfo(packageName, PackageManager.GET_PERMISSIONS); Date installTime = new Date( packageInfo.firstInstallTime ); Log.d(TAG, "Installed: " + installTime.toString()); Date updateTime = new Date( packageInfo.lastUpdateTime ); Log.d(TAG, "Updated: " + updateTime.toString()); } catch ( PackageManager.NameNotFoundException e ) { e.printStackTrace(); } </code></pre> <p>You can also change the date format with <a href="http://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html" rel="noreferrer">java.text.SimpleDateFormat</a>. </p> <pre><code>SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String installTime = dateFormat.format( new Date( packageInfo.firstInstallTime ) ); Log.d(TAG, "Installed: " + installTime); String updateTime = dateFormat.format( new Date( packageInfo.lastUpdateTime ) ); Log.d(TAG, "Updated: " + updateTime); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload