保持帐户信息在机器人工作室的所有活动 [英] Keep the account info in all activities in android studio

查看:171
本文介绍了保持帐户信息在机器人工作室的所有活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序是一个简单的管理数据库应用程序。我有一个远程MySQL服务器设置和我的Andr​​oid Studio应用程序使用HTTP POST请求连接到该服务器。

My application is simply a managing database application. I have a remote mysql server set up and my android studio application uses http post request to connect to that server.

咋办我想保留的所有活动,如用户名帐户信息,密码。现在我用的是putExtra()来传输,并保持在所有活动中的账户信息,但它看起来很复杂。我每次开始一个新的活动,我需要putextra()把我的帐户信息,有没有一种简单,更好的方式来accoumplish呢?

Supposed I want to keep the account information like username, password in all activities. Right now I use the putExtra() to transfer and keep the account information in all activities but it seems complicated. Every time I start a new activity and I need the putextra() to transfer my account information, is there a easy and better way to accoumplish this?

推荐答案

许多选项:

1)静态变量创建一个全局类。

1) Create a global class with static variables.

2)扩展了应用程序类和存储信息在里面。

2) Extend the Application class and store information in it.

2)如果只是两三个参数,可以将其存储在共享preferences。

2) If it's just two-three parameters, you can store it in shared preferences.

这篇关于保持帐户信息在机器人工作室的所有活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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