title: ERROR: on a null object reference
body: <p>I don't know what's wrong in my code</p>
  
  <p>this is my Fragment class</p>
  
  <pre class="lang-html prettyprint-override"><code>package com.example.gandi.symanlub;
  
  
  /**
   * A simple {@link Fragment} subclass.
   */
  public class Reminder extends Fragment {
  
      Button btnubah, btnkeluar;
      SessionManager session;
  
      View rootview;
  
  
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
          // Inflate the layout for this fragment
          rootview = inflater.inflate(R.layout.fragment_reminder, container, false);
  
          btnkeluar = (Button)rootview.findViewById(R.id.btnlogout);
          btnkeluar.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  session.logoutUser();
              }
          });
  
          return rootview;
  
      }
  
  }
  </code></pre>
  
  
  
  <p>and this is my SessionManager.java</p>
  
  <pre class="lang-html prettyprint-override"><code>package com.example.gandi.symanlub;
  
  @SuppressLint("CommitPrefEdits")
  public class SessionManager {
      // Shared Preferences
      SharedPreferences pref;
  
      // Editor for Shared preferences
      SharedPreferences.Editor editor;
  
      // Context
      Context _context;
  
      // Shared pref mode
      int PRIVATE_MODE = 0;
  
      // nama sharepreference
      private static final String PREF_NAME = "Sesi";
  
      // All Shared Preferences Keys
      private static final String IS_LOGIN = "IsLoggedIn";
      public static final String KEY_EMAIL = "email";
      public static final String KEY_PASS = "pass";
  
  
  
      // Constructor
      public SessionManager(Context context){
          this._context = context;
          pref = _context.getSharedPreferences(PREF_NAME, PRIVATE_MODE);
          editor = pref.edit();
      }
  
      /**
       * Create login session
       * */
      public void createLoginSession(String email, String pass){
          // Storing login value as TRUE
          editor.putBoolean(IS_LOGIN, true);
  
          editor.putString(KEY_EMAIL, email);
          editor.putString(KEY_PASS, pass);
          editor.commit();
      }
  
      /**
       * Check login method wil check user login status
       * If false it will redirect user to login page
       * Else won't do anything
       * */
      public void checkLogin(){
          // Check login status
          if(!this.isLoggedIn()){
              Intent i = new Intent(_context, Login.class);
              i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
              i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
              _context.startActivity(i);
              //((Activity)_context).finish();
          }
  
      }
  
      /**
       * Get stored session data
       * */
      public HashMap&lt;String, String&gt; getUserDetails(){
          HashMap&lt;String, String&gt; user = new HashMap&lt;String, String&gt;();
  
          user.put(KEY_EMAIL, pref.getString(KEY_EMAIL, null));
          user.put(KEY_PASS, pref.getString(KEY_PASS, null));
  
          return user;
      }
  
      /**
       * Clear session details
       * */
      public void logoutUser(){
          editor.clear();
          editor.commit();
      }
  
      public void hapussesi(){
          editor.clear();
          editor.commit();
      }
  
      public boolean isLoggedIn(){
          return pref.getBoolean(IS_LOGIN, false);
      }
  }
  </code></pre>
  
  
  
  <p>the error when I run the project :</p>
  
  <p>java.lang.NullPointerException: Attempt to invoke virtual method 'void com.example.gandi.symanlub.SessionManager.logoutUser()' on a null object reference</p>