saving/loading 控制数据的推荐 read/write 做法

Recommended read/write practices for saving/loading control data

我已经阅读了 android 开发文档和此处的一些文档,但我仍然对采用的方法有些困惑。现在我正在构建一个小型 Android 应用程序,它实际上只是一个小型 POS(销售点)应用程序。

我希望用户能够保存物品(库存)的价格,并能够在以后重新使用这些价格。我不想让用户在每次使用该应用程序时都输入商品价格。

现在我在共享资源和 filesystem/file 之间挣扎。

问题: 在这种情况下,最好的路线是什么?当用户创建新订单时,获取价格的最佳方式是什么?

是否建议 class 也包含这些值,而不仅仅是从文件中读取?

Activity/Class 文件的比例是否必须为 1 比 1?你能在不启动 activity 的情况下实例化 Class 吗?

In this situation, what is the best route? When the user creates a new order, what is the best way of getting the prices?

我建议您使用 CursorLoader 并在您的 onCreate 方法中调用它。不要忘记在关闭 activity 之前释放这些资源。

Do you have to have a 1 to 1 ratio of Activity/Class files?

不,你不知道。

Can you instantiate a Class without starting the activity?

是的,你可以。