在应用程序设置保存用户信息 [英] Saving user information in app settings

查看:186
本文介绍了在应用程序设置保存用户信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序创建登录。用户键入他的信息我将其发送给Web服务,检查,并得到他的身份证。现在我需要的地方保存在我的应用程序,我可以检查他是否登录。

i am creating login in my app. User type his info i send it to web service to check and get his ID. Now i need to save it somewhere in my app that i could check if he had login.

那么,这个信息应该被保存?我知道,每一个应用程序有它的设置,所以应该有这个信息?也许有人可以给我更多的信息是什么以及如何做。

So where this info should be saved ? I know that every app have it's settings so there should be this info ? Maybe someone could give me more info what and how this is doing.

感谢。

我发现这个职位: <一href="http://stackoverflow.com/questions/785973/what-is-the-most-appropriate-way-to-store-user-settings-in-android-application">What是最合适的方式来存储在Android应用程序用户设置

I found this post: What is the most appropriate way to store user settings in Android application

我相信我的问题是重复的。但是,如果你有什么分享更多就好了。

I believe my question was duplicate. But it would be nice if you have something to share more.

推荐答案

首先喜欢的uname和放所有保存用户信息;密码共享preferences与此code。

First of all save user info like uname & password in SharedPreferences with this code.

SharedPreferences settings = getSharedPreferences("UserInfo", 0);
SharedPreferences.Editor editor = settings.edit();
editor.putString("Username",txtUname.getText().toString());
editor.putString("Password",txtPWD.getText().toString());
editor.commit();

,然后得到以下code共享preferences

and then get SharedPreferences from below code

SharedPreferences settings = getSharedPreferences("UserInfo", 0);
txtUname.setText(settings.getString("Username", "").toString());
txtPWD.setText(settings.getString("Password", "").toString());

这篇关于在应用程序设置保存用户信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆