0

I want the first install time on android version 2.2. I have done in android 2.3, how to do in android 2.2 Here is my code

try 
    {
        long installed = context.getPackageManager().getPackageInfo("com.simsys.securex", 0).firstInstallTime;
        String DateTimeStamp=getDate(installed, "dd/MM/yyyy hh:mm:ss");
        String dateTimeSync="Installed_Date:";
        String dateTimeSync2=dateTimeSync.concat(DateTimeStamp);
        TextView txtCurrentTime= (TextView)findViewById(R.id.textViewdatetime);
        txtCurrentTime.setText(dateTimeSync2);
    }
    catch (NameNotFoundException e) 
    {
        e.printStackTrace();
    }
Tirtha
  • 351
  • 2
  • 6
  • 22

1 Answers1

1
PackageManager packageManager = context.getPackageManager();
ApplicationInfo appInfo = packageManager.getApplicationInfo("com.simsys.securex", 0);
String sourceDir= appInfo.sourceDir;
long dateTimeSync= new File(sourceDir).lastModified();
Tanmay Mandal
  • 39,873
  • 12
  • 51
  • 48
  • 2
    In case there is an update version, and if the user updates the app, this will return last update time. – SheIs_LeThiCongNhan Aug 01 '12 at 07:15
  • 2
    @TanmayMandal That's actually a really important point because if you're looking for the first install time, and not the modified time then your answer is not correct. I would expect the first install time to never change once set. – Christopher Perry Aug 28 '12 at 05:12