Buggy code:
public class LoginFragment extends Fragment { private static final String ARG_PARAM1 = "param1" ; private static final String ARG_PARAM2 = "param2" ; private String mParam1 ; private String mParam2 ; private LoginFragment . OnFragmentInteractionListener mListener ; private EditText name ; private EditText passw ; private Button login ; private Button registration ; public static LoginFragment newInstance ( String param1 , String param2 ) { } public LoginFragment ( ) { } @ Override public void onCreate ( Bundle savedInstanceState ) { } @ Override public View onCreateView ( LayoutInflater inflater , ViewGroup container , Bundle savedInstanceState ) { } public void onButtonPressed ( Uri uri ) { } @ Override public void onAttach ( Activity activity ) { } @ Override public void onDetach ( ) { } @ Override public void onActivityCreated ( Bundle savedIstanceState ) { super . onActivityCreated ( savedIstanceState ) ; Typeface type = Typeface . createFromAsset ( getActivity ( ) . getAssets ( ) , "fonts//Roboto-Regular.ttf" ) ; name = ( ( EditText ) ( getActivity ( ) . findViewById ( logName ) ) ) ; passw = ( ( EditText ) ( getActivity ( ) . findViewById ( logPass ) ) ) ; login = ( ( Button ) ( getActivity ( ) . findViewById ( loginButton ) ) ) ; registration = ( ( Button ) ( getActivity ( ) . findViewById ( logRegButton ) ) ) ; SpannableString title = new SpannableString ( "Login" ) ; title . setSpan ( type , 0 , title . length ( ) , SPAN_EXCLUSIVE_EXCLUSIVE ) ; ActionBar actionBar = getActivity ( ) . getActionBar ( ) ; actionBar . setTitle ( title ) ; name . setTypeface ( type ) ; passw . setTypeface ( type ) ; login . setTypeface ( type ) ; registration . setTypeface ( type ) ; registration = ( ( Button ) ( getActivity ( ) . findViewById ( logRegButton ) ) ) ; registration . setOnClickListener ( new View . OnClickListener ( ) { @ Override public void onClick ( View v ) { RegistrationFragment registrationFragment = new RegistrationFragment ( ) ; FragmentManager fragmentManager = getFragmentManager ( ) ; FragmentTransaction fragmentTransaction = fragmentManager . beginTransaction ( ) ; fragmentTransaction . setCustomAnimations ( slide_in_left , slide_out_right ) ; fragmentTransaction . replace ( container , registrationFragment ) ; fragmentTransaction . commit ( ) ; } } ) ; login . setOnClickListener ( new View . OnClickListener ( ) { @ Override public void onClick ( View v ) { <START_BUG> SharedPreferences preferences = getActivity ( ) . getSharedPreferences ( UUID , getActivity ( ) . MODE_PRIVATE ) ; <END_BUG> String User = preferences . getString ( "username" , null ) ; String Pass = preferences . getString ( "password" , null ) ; if ( ( User != null ) && ( Pass != null ) ) { if ( ( name . getText ( ) . toString ( ) . equals ( User ) ) && ( passw . getText ( ) . toString ( ) . equals ( Pass ) ) ) { Toast . makeText ( getActivity ( ) , "Login" , LENGTH_SHORT ) . show ( ) ; } else { Toast . makeText ( getActivity ( ) , "Wrong<seq2seq4repair_space>username<seq2seq4repair_space>or<seq2seq4repair_space>password" , LENGTH_SHORT ) . show ( ) ; } } else { Toast . makeText ( getActivity ( ) , "You<seq2seq4repair_space>must<seq2seq4repair_space>first<seq2seq4repair_space>register" , LENGTH_SHORT ) . show ( ) ; } Intent intent = new Intent ( getActivity ( ) . getApplicationContext ( ) , ChatActivity . class ) ; startActivity ( intent ) ; } } ) ; } public interface OnFragmentInteractionListener { public void onFragmentInteraction ( Uri uri ) { } } }

Fix:
SharedPreferences preferences = getActivity ( ) . getSharedPreferences ( "preferences" , getActivity ( ) . MODE_PRIVATE ) ;