我应该使用SQLite [英] Should I use Sqlite

查看:165
本文介绍了我应该使用SQLite的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我说这个我没有做过并使用SQLite应用
我正在开发一个类似的调查project.I要保存回答用户的提问一个字符串数组和一个整数数组的答案(有5个选择,它们保存到数组作为0,1,2,3,4),当用户关闭该项目。
我应该使用SQLite?有没有一个更合乎逻辑的方式?

First I say this I have not done before and the application with Sqlite I'm developing a similar survey project.I want save a string array for user's questions answered and an integer array for answer(there are 5 choice and they are saving to array as 0,1,2,3,4) when user closes the project. Should I use Sqlite?is there a more logical way?

推荐答案

我会说不,如果你保存的东西是pretty简单。结果
我将使用SQLite的情况下,你需要一些relationalship或复杂查询。你的情况,你可能只存储在共享preferences一切(如果你能告诉我们一个例子,我们可以引导你)。

I would say "no", if the stuff that you're saving is pretty simple.
I would use sqlite in case you need some relationalship or "complex" query. In your case you can probably just store everything in the SharedPreferences (if you can tell us an example we can guide you).

您也可以考虑写入文件的对象(地图,或列表,或其他),或将其保存为JSON。

You can also consider to write to a file your object (a map, or a list, or whatever), or saving it as json.

File file = new File(context.getDir("data", Context.MODE_PRIVATE), PRESETS);
ObjectOutputStream outputStream = new ObjectOutputStream(new FileOutputStream(file));
outputStream.writeObject(myObject);
outputStream.flush();
outputStream.close();

这篇关于我应该使用SQLite的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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