FAQS


How to get Package details?

Views: 1881  |   Date: 2013-08-30 21:51:42

Get package versionCode and versionName as defined in manifest.xml file.


Example :


  
	package="com.textonhold.library" android:versionName="2.10.9" android:versionCode="224"> 

Answer 1

Get PackageManager refference to get android project package details.

    
 PackageManager manager = this.getPackageManager();

 try {
	  PackageInfo info = manager.getPackageInfo(this.getPackageName(), 0);
        Log.i(TAG, "VersionCode:"+info.versionCode +" VersionName:"+info.versionName);
     } 
   catch (NameNotFoundException e) 
     {
        Log.i(TAG, "NameNotFoundException caught: " + e.getMessage());
     }
   catch (Throwable t) 
     {
        Log.i(TAG,"Throwable caught: " + t.getMessage());
     }

 
Submit Your Answer
  |  
 
 
 

Preview :