使用共享preferences主场迎战Android的捆绑 [英] Using shared preferences vs. bundle in Android

查看:132
本文介绍了使用共享preferences主场迎战Android的捆绑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在1和2打记录之间做检索表的数据库,使数据的某些部分可以在应用程序中使用的应用程序(该表有6个字段)。它不需要在设备上永久保存。是共享使用这样的事情preferences或者我应该利用捆绑?

The app I'm making retrieves between 1 and 2 dozen records from a table in a DB so that certain pieces of data can be used during the app (the table has 6 fields). It won't need to be stored permanently on the device. Is shared preferences used for something like this or should I be utilizing a bundle?

推荐答案

您可以直接查询数据库,并得到你想要的数据并将其存储在变量正常方式。

You can just query the db and get the data you want and store it in a normal fashion in variables.

共享preferences 主要用于当你想不同的应用执行之间保留数据

SharedPreferences is mainly used when you want to retain data between different app executions.

捆绑当你想活动之间或活动与片段之间安全地传输数据使用。

Bundle is used when you want to safely transfer data between activities or between an activity and a fragment.

所以,除非你有这样的要求,你可以将它们存储在正常的变量

So unless you have some such requirements, you can just store them in normal variables.

这篇关于使用共享preferences主场迎战Android的捆绑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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