简体   繁体   English

如何在Android中管理字符串资源

[英]How to manage string resources in Android

I have to use many url strings in Android project. 我必须在Android项目中使用许多网址字符串。

First I stored them as class variable but there are so many strings so I tried to store them as string resources in strings.xml . 首先,我将它们存储为class variable但是有太多字符串,因此我尝试将它们作为字符串资源存储在strings.xml However it's too hard since url includes a lot of special characters like &, /, % I have to convert them using <![CDATA[]> . 但是,这太难了,因为url包含很多特殊字符,例如&, /, %我必须使用<![CDATA[]>进行转换。

What is the most effiecient way to store those strings in Android? 在Android中存储这些字符串的最有效方法是什么?

If they are URLs, there is no point in storing them in strings.xml. 如果它们是URL,则没有必要将它们存储在strings.xml中。 Strings.xml is for internationalization and localization and URLs don't need that. Strings.xml用于国际化和本地化,URL不需要。 So store them in a constants class like you were doing before. 因此,像以前一样将它们存储在常量类中。

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

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