简体   繁体   English

在android中存储和检索大量文本数据的最有效方法

[英]Most efficient way to store and retrieve large amounts of text data in android

I wanna write an android application which will store and retrieve large amounts of text data. 我想写一个Android应用程序,它将存储和检索大量的文本数据。 I wanna store text in paragraph wise.I need to manipulate this text data in an efficient way. 我想在段落中存储文本。我需要以有效的方式操作这些文本数据。 What will be the best way for doing this? 这样做的最佳方式是什么?

I think the best way is to save all data inside a file. 我认为最好的方法是将所有数据保存在文件中。 And save this file to specified location in sdcard. 并将此文件保存到SD卡中的指定位置。 If you are saving data inside a file you will get same format as you saved(eg Paragraph wise in your case).And you can delete file when ever you want. 如果要将数据保存在文件中,您将获得与保存时相同的格式(例如,在您的情况下为Paragraph)。您可以随时删除文件。

I found this may this help you to solve your issue 我发现这可能有助于您解决问题

SharedPreferences is apparently implemented internally as an XML file which is serialized and deserialized in full on update. SharedPreferences显然在内部实现为XML文件,在更新时将其完整地序列化和反序列化。 And it's a Key-Value store with no index. 它是一个没有索引的Key-Value商店。 So use that only for simple data associated with your app. 因此,仅将此用于与您的应用相关联的简单数据。 Any more than 50 keys and you've probably overdone it. 任何超过50个键,你可能已经过度了。

ContentProvider is intended for sharing data across applications. ContentProvider旨在跨应用程序共享数据。 You've explicitly said you don't want to do that. 你明确表示你不想这样做。

SQLiteDatabase is intended for individual apps to store data, and provides a lot of flexibility to store and index data in different ways. SQLiteDatabase旨在供各个应用程序存储数据,并提供了以不同方式存储和索引数据的大量灵活性。 I personally use it to store logs in one of my apps. 我个人用它来存储我的一个应用程序中的日志。 I'd recommend that route. 我推荐那条路线。

See this discussion for more details 有关详细信息,请参阅此讨论

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

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