Skip to content

Instantly share code, notes, and snippets.

@dhavaln
Created April 3, 2016 08:03
Show Gist options
  • Save dhavaln/304472752f3e4064cb3c1995bd398f8f to your computer and use it in GitHub Desktop.
Save dhavaln/304472752f3e4064cb3c1995bd398f8f to your computer and use it in GitHub Desktop.
Detect whether app is installed or updated
import android.content.pm.PackageInfo;
/*
* Utility class to check whether App is Updated of Fresh Installed
*/
public class AppInfoUtil{
public boolean isUpdated() throws Exception{
PackageInfo info = null;
info = getPackageManager().getPackageInfo(getPackageName(), 0);
return info.firstInstallTime != info.lastUpdateTime;
}
public boolean isNewInstalled() throws Exception{
PackageInfo info = null;
info = getPackageManager().getPackageInfo(getPackageName(), 0);
return info.firstInstallTime == info.lastUpdateTime;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment