我想比较字符串从EditText字段到共享首选项中的字符串。如果字符串匹配新的活动开始。 Sharedpreferenced中的字符串使用Base64进行编码。我试图在解码后将编辑文本字符串与sharedpreferences字符串进行比较,但无法获得正确的编码。我怎样才能正确地编码。例子表示赞赏。我的比较器在线路77和78字符串比较瓦特/如果语句
44. public void onClick(View arg0) {
45.
46. sp=this.getSharedPreferences("AccessApp", MODE_WORLD_READABLE);
47.
48.
49.
50.
51. byte[] key = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5 };
52.
53.
54. try {
55. user = sp.getString("USERNAME_KEY", null);
56. String decryptedUser = decrypt(user, key);
57.
58.
59. }
60. catch (Exception e) {
61. // TODO Auto-generated catch block
62. e.printStackTrace();
63. }
64. try {
65. pass = sp.getString("PASSWORD_KEY", null);
66. String decryptedPass = decrypt(pass, key);
67.
68.
69.
70. } catch (Exception e) {
71. // TODO Auto-generated catch block
72. e.printStackTrace();
73. }
74.
75. if(lBttn.equals(arg0)){
76.
77. if((uname.getText().toString().equals(decryptedUser)) &&
78. (pword.getText().toString().equals(decryptedPass)))
79.
80. {
81. Toast.makeText(this, "You are Logged In", 20000).show();
82.
83. Intent intent;
84. intent=new Intent(this,details.class);
85. startActivity(intent);
86. flag=1;
87. }
什么一些Log.d调味你的代码(),显示你在哪里,你的琴弦实际上是谁? Usuallz这有助于了解发生了什么 –
这是什么声明“if(lBttn.equals(arg0))”? 你的结果有什么问题?我认为如果条件好。它会重新产生错误的结果吗? –
引用了OnClick方法。 – user1165694