getSharedPreferences保存或获取

 SharedPreferences sp = context.getSharedPreferences("user", Context.MODE_PRIVATE);
        sp.edit().putString("username",data1.getUsername())
                .putString("userpass",data1.getPassword()).commit();
 SharedPreferences sp = context.getSharedPreferences("user", Context.MODE_PRIVATE);
        String username = sp.getString("username", "");
        String userpass = sp.getString("userpass", "");

你可能感兴趣的:(getSharedPreferences保存或获取)