title: How to create public method?
body: <p>This is a newbie type question. I want to create a public method that can be accessed by any activity in the application. The method I am trying to create is a simple method to show the versionName or VersionCode. here is the code I use in a private method, I just feel like there has got to be a simple way of making this method accessible to all my activities without having to add the private method code to each activity individually, and simply adding a public descriptor doesn't seem to work...
  Thank you!</p>
  
  <p>method:</p>
  
  <pre><code>private PackageInfo getPackageInfo() {
          PackageInfo pi = null;
          try {
               pi = this.getPackageManager().getPackageInfo(this.getPackageName(), PackageManager.GET_ACTIVITIES);
          } catch (PackageManager.NameNotFoundException e) {
              e.printStackTrace();
          }
          return pi;
      }
  </code></pre>
  
  <p>example usage:</p>
  
  <pre><code>@Override
      public boolean onOptionsItemSelected(MenuItem item) {
          PackageInfo versionInfo = getPackageInfo(); 
          String about = new String(
                      versionInfo.versionName +"\n" + getString(R.string.about));
  </code></pre>