简体   繁体   English

从.txt文件或从预加载的SQLite数据库加载数据到私有数据库是否更好?

[英]Is it better to load data from a .txt file or from a preloaded SQLite database into a private database?

I'm working on an Android app and I wonder if it is better to load data from a .txt file or from a preloaded SQLite db. 我正在开发一个Android应用程序,我想知道从.txt文件还是从预加载的SQLite数据库加载数据是否更好。

When I take data from a .txt file, I do the following: ("insertar" is a function that inserts key and value into db) 从.txt文件中获取数据时,我将执行以下操作:(“ insertar”是将键和值插入db的函数)

while ((line = buffreader.readLine()) != null) {
    keyValue = new String[2];
    keyValue = line.split("_");
    insertar(keyValue[0], keyValue[1]);
}

I haven't coded a function to copy data from a preloaded database yet. 我还没有编写一个函数来从预加载的数据库中复制数据。

Do I have any other option in order to be as fast as possible on the first app launch? 我是否还有其他选择,以便在首次启动应用程序时尽可能快? Which is the most performant method to load data? 哪种数据加载方式最有效?

It depends on what you want to do if you want to save a few keywords i woud use SharedPreferences api (this shoud be the perfomantest option). 如果要保存一些我要使用SharedPreferences api的关键字(这应该是perfomantest选项),这取决于您要执行的操作。 if you want to keep it simple fort he user the see the data i woud take a txt file. 如果您想让用户保持简单,请参阅我将使用txt文件的数据。 If you want to save few data i woud take the datapase. 如果您想保存很少的数据,我将使用datapase。 As you can see it depends on the situation. 如您所见,这取决于情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM