title: counting android app using with SharePrefrence and doesn't initialize sharePrefrence
body: <p>I want to create in-app-purchasing duo to control times of using my app with <code>SharedPreferences</code>. 
  I have  3 activities:</p>
  
  <ul>
  <li>FirstActivity - shows just at the first time</li>
  <li>MainActivity  </li>
  <li>MyketActivity-- include <code>SharedPreferences</code> and in-app-purchasing code</li>
  </ul>
  
  <p><code>FirstActivity</code> shows just at the first time of app running and <code>myket.getLogginTime(1)</code> (<code>loggin_time_SharePrefrence</code> saves <code>1</code> time). 
  next time, app runs from <code>MainActivity</code> and <code>myket.getLogginTime(1)</code> (<code>loggin_time_SharePrefrence</code> saves <code>2</code> time).
   finally the TIME checks with <code>checkLogginTime</code>.</p>
  
  <p>but as I run my app,it crashed in FirstActivity and showed me:</p>
  
  <pre><code>java.lang.NullPointerException: Attempt to invoke virtual method 'void getLogginTime(int)' on a null object reference
                    at myketActivity.java 
  </code></pre>
  
  <p>in FirstActivity.java:</p>
  
  <pre><code>  public class FirstActivity extends Activity {
           public MyketActivity myketActivity = new MyketActivity();
  ...
  
      myketActivity.getLogginTime(1); // this is the first time
  }
  </code></pre>
  
  <p>in MyketActivity.class:</p>
  
  <pre><code>public class MyketActivity extends Activity {
  public static SharedPreferences loggin_time_SharePrefrence;
  public static SharedPreferences.Editor editor_logginTimer;
  private int times_of_getting_premium = 2;
  public static final int loggin_time=0;
  public BackDialog purchaseDialog;
  
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.myket);
  
      //in app purchasing
      loggin_time_SharePrefrence = getSharedPreferences("times", Context.MODE_PRIVATE);
      editor_logginTimer = loggin_time_SharePrefrence.edit();
  
  
       //loggin_time=loggin_time_SharePrefrence.getInt("times",loggin_time);
  ...
         }//on create
  public void getLogginTime (int i){
      editor_logginTimer.putInt("times",i).commit();
  }
  
  public int checkLogginTime(){
     int t= loggin_time_SharePrefrence.getInt("times",loggin_time);
      return t;
  }
  </code></pre>
  
  <p>How can I solve it? Thanks!  </p>