在Android应用程序在本地保存的Facebook登录信息 [英] Saving facebook login details locally in android app
问题描述
我正在开发Android应用程序,用户拥有Facebook的共享设施。我有用户为Facebook的登录信息,现在我所要做的是,这些登录信息应保存,直到应用程序不会被删除。
当我试图找到这个答案,我得到了一些答案,说明有关共享preferences。但我不清除它究竟是如何工作的。
下面就是我要做的,
=用户名username.getText()的toString()。。PASSWORD = password.getText()的toString();
,其中用户名和密码2的EditText领域。当用户首次进入Facebook的进入,我应该什么地方保存这些数据对我今后的参考,使他不必重新登录。
任何一个可以让我知道如何实现这一目标?
//保存您的信息
共享preferences设置= getShared preferences(my_file_name,0);
共享preferences.Editor编辑= settings.edit();
editor.putString(用户名,username.getText()的toString());
editor.putString(密码,password.getText()的toString());
editor.commit();//获取您的信息
共享preferences设置= getShared preferences(my_file_name,0);
字符串username = settings.getString(用户名,);
字符串密码= settings.getString(密码,);
一个文件中创建:
数据/数据/ [your.package.path] / shared_ preFS / [your.package.path] _ preferences.xml
I am developing an Android app where the user has the facility of Facebook sharing. I have the login details of the user for the Facebook, now what I am trying to do is these login details should be saved until the application is not deleted.
When I tried to find the answer for this, I got some answers stating about shared preferences. But I am not cleared exactly how it works.
Here is what I am trying to do,
Username = username.getText().toString();
PassWord = password.getText().toString();
where username and password are 2 edittext fields. When the user enters for the first time into Facebook, I should save these data somewhere for my future reference so that he need not login again.
Can any one let me know how to achieve this?
// Save your info
SharedPreferences settings = getSharedPreferences("my_file_name", 0);
SharedPreferences.Editor editor = settings.edit();
editor.putString("username", username.getText().toString());
editor.putString("password", password.getText().toString());
editor.commit();
// Obtain your info
SharedPreferences settings = getSharedPreferences("my_file_name", 0);
String username = settings.getString("username", "");
String password = settings.getString("password", "");
A file will be created in:
data/data/[your.package.path]/shared_prefs/[your.package.path]_preferences.xml
这篇关于在Android应用程序在本地保存的Facebook登录信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!