SharedPreferences sharedPreferences = context.getSharedPreferences("user",Context.MODE_PRIVATE);
Editor editor = sharedPreferences.edit();
editor.putInt("userId",1);
editor.commit();
SharedPreferences sharedPreferences = context.getSharedPreferences("user",Context.MODE_PRIVATE);
sharedPreferences.getInt("userId",-1);