Android – 让用户登录

我正在尝试使用PHP和MySQLi for Android进行登录。 我不明白的是如何让用户登录? 我看到一个简单的教程,其中有人使用SQLite来获取安全信息,但我不知道这是否真的是安全的。 我应该如何保存用户信息以保持用户登录?

谢谢。

使用android中的SharedPreferences

当您的登录使用时存储数据

 SharedPreferences pref = getApplicationContext().getSharedPreferences("MyPref", 0); // 0 - for private mode Editor editor = pref.edit(); //on the login store the login editor.putLong("key_name", "long value"); editor.commit(); 

检索密钥的数据

 pref.getString("key_name", ""); ^ default value if the user is not loggedin 

注销时清除数据

 editor.remove("name"); editor.commit(); 

请参阅此链接了解更多信息