什么本地存储最适合 android 列表
我有一个形状列表——三角形、正方形、长方形、五角形。这些形状是通过文本字段输入的,并在稍后根据提示调用时显示文本。可能会有大约 200 个条目。
这具体是如何完成的?我看到有很多方法,但我无法从描述中看出哪一种最好?
I have a list of Shapes--Triangle, Square, Rectangle, Pentagram. These shapes were input via a text field and recalled to display the text later on cue. There will probably be around 200 entries.
How exactly is this done? I have seen that there are a lot of ways, but I couldn't tell by the descriptions which one is best?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你可以查一下ArrayList。它的工作原理类似于向量。存储数据的好方法。
如果你想将其存储到数据库中,可以通过 SQLite(Android 中的内置数据库)来完成。
You can look up at ArrayList. It works like a Vector. A great way to store your data.
If you want to store it to a database, you can do it via SQLite, a built in database in Android.
如果您有最大尺寸或确切知道有多少个形状,则应该使用 Shape[]。
如果您不知道需要存储多少形状,则应该使用列表。
如果您希望在退出应用程序时保存此项目列表,并在用户重新启动时再次加载,请使用 sqllite。不要经常使用sqllite,通常您希望在启动时从数据库加载,并在关闭时写入数据库。
If you have a max size or know exactly how many shapes there are, you should use a Shape[].
If you don't know how many shapes you will need to store, you should use a List.
Use sqllite if you want this list of items to be saved when you quit the app, and loaded again when the user restarts. Don't use sqllite constantly, generally you want to load from you database when starting, and write to the database when closing.
静态最终ArrayList> arraylistobject = new ArrayList>();
private void yourFunctionName()
{
}
您可以使用上面定义的带有 hashmap 的数组列表,然后您可以将所有形状的列表添加到本地存储中。
static final ArrayList> arraylistobject = new ArrayList>();
private void yourFunctionName()
{
}
you can use the above define arraylist with hashmap and then you can add all shapes of list inti local storage .