Android studio ignoring sharedPreference code

I have tired using sharedpreference to store session and used Log to test if information are stored. However, android studio seems to skip past code that involve sharedpreference. Am i doing anything wrong?

Global

public static final String MyPREFERENCES = "MyPrefs" ;
public static final String EmployeeID = "employeeID";
public static final String EmployeeName = "employeeName";
SharedPreferences sharedpreferences;

OnCreate

sharedpreferences = getSharedPreferences(MyPREFERENCES, Context.MODE_PRIVATE);
    String user = sharedpreferences.getString("EmployeeName", "");
    if (user.equalsIgnoreCase("")) {
        Log.i("Status", "No session detected");
    } else {
        Intent i = new Intent(getApplicationContext(), MainActivity.class);
        startActivity(i);
    }


protected void onPostExecute(Employee results){
        if (results != null){

            SharedPreferences.Editor editor = sharedpreferences.edit();

            editor.putString(EmployeeID, results.getEmployeeID());
            editor.putString(EmployeeName, results.getFirstName()+" "+results.getLastName());
            editor.apply();
            editor.commit();
            Log.i("aaaaaaaa", "hellloooo"); // It print this libe
            String a = sharedpreferences.getString("EmployeeID", "");
            Log.i("aaaaaaaa", a); // but not this line
            Toast.makeText(LoginActivity.this, " Authenticated", Toast.LENGTH_SHORT).show();
            Intent i = new Intent(getApplicationContext(), MainActivity.class);
            startActivity(i);

        }
        else {
            Toast.makeText(LoginActivity.this, "Invalid ID", Toast.LENGTH_SHORT).show();
        }
    }