什么是坚持名单的最有效的方法是什么? [英] What is the most efficient way of persisting lists?

查看:151
本文介绍了什么是坚持名单的最有效的方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建一个Android应用程序,允许用户创建的朋友不同的列表。对于每个列表,项目有一个名字和2参数...

I am creating an Android application that allows the user to create different lists of friends. For each list, the items have a name and 2 parameters...

示例

表1:(史蒂夫,参数1,参数2),(丽莎,参数1,参数2)...等

List 1: (Steve, param 1, param 2), (Lisa, param 1, param 2)... etc

列表2:(约翰,参数1,参数2),(史蒂夫,参数1,参数2)...等
...

List 2: (John, param 1, param 2), (Steve, param 1, param 2)... etc ...

什么是动态坚持由用户创建的所有这些名单的最佳方式?

What is the best way of dynamically persisting all these lists created by the user?

我在想使用SQLite,因为它是很容易实现的。

I was thinking about using SQLite since it is quite easy to implement.

我也不过大约用普通JSON文件的工作,但这种方法似乎太消耗资源,因为添加,读取,修改的东西应用程序处理...

I also though about working with plain JSON files, but this approach seemed too resource consuming, because the application deals with adding, reading, modifying stuff...

那么,什么是坚持这些对象的最佳方式?

So, what is the best way of persisting these objects?

如果我使用一个数据库,我认为应该有以下方案:

If I use a database, I thought it should have the following scheme:

PERSONS - 列:PERSON_ID,PERSON_NAME

列表 - 列:列表

有关列表,每行只是通过某种元组的集合,再presenting一个列表构成。

For LISTS, each row is just formed by some sort of set of tuples, representing a single list.

示例

第1行:[(PERSON_ID,参数1,参数2),(PERSON_ID,参数1,参数2),...]

Row 1: [(Person_ID, param1, param2), (Person_ID, param1, param2), ...]

其中第1行与所有包含在它的人一个列表。

Where Row 1 is a single list with all the people contained in it.

不幸的是这似乎并不十分有效......

Unfortunately this doesn't seem very efficient....

我也想过创建一个额外的表

I also thought about creating an extra table

LIST_ROW - 列:ROW_ID,PERSON_ID,参数1,参数2

,然后在列表中表的每一行也只是标识的所有行的元组属于该列表...

and then each row in the LISTS table would just be a tuple of IDs for all the rows that belong to that list...

示例

第1行会刚刚成为:(ROW_ID,ROW_ID ....)再presenting的元素列表1

Row 1 would just become: (row_id, row_id....) representing the elements in the list 1.

不幸的是,我不知道如何有效的,这是。

Unfortunately, I am not sure on how efficient this is.

有人能告诉我什么是实现这一目标的最佳途径?

Can someone tell me what is the best way of achieving this?

推荐答案

您可以使用此共享preferences。转换列表为String(逗号sepereated对象和值),则添加此共享prefrences。在同样的方式,你可以得到这并转换到您的列表。

You can use shared preferences for this. Convert your list to a String(comma sepereated objects and values) then add this is shared prefrences. In same way you can get this and convert to your list.

这篇关于什么是坚持名单的最有效的方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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