简体   繁体   English

Android如何在共享的首选项中存储跨区文本

[英]Android How to store spanned text in shared preferences

the Html parse is very slow, so I thought of storing a static text within the sharded preferences to access it faster. HTML解析非常慢,因此我想到了在分片首选项中存储静态文本以更快地访问它。 Is it possible to store this somehow and retrieve it, so that it can be set without usage of Html.fromHtml? 是否可以以某种方式存储和检索它,以便可以在不使用Html.fromHtml的情况下进行设置?

This way I would just parse the file one time. 这样,我将只解析一次文件。 Once it is in cache it should be much faster, if no parsing is required. 一旦将其保存在缓存中,如果不需要解析,它应该会更快。

Yes you can store Static string in shared preferences. 是的,您可以将静态字符串存储在共享首选项中。

Here is code which may help you.. 这是可以帮助您的代码。

SharedPreferences sharedPref = getPreferences(Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPref.edit();        
editor.putString(YOUR_KEY, YOUR_STATIC_STRING);
editor.commit();

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

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