我在我的应用程序中有很多字符串,但我不想将它存储在那里,因为它只会使我的应用程序变大。无论如何,从服务器检索字符串?如何从远程服务器检索字符串?
0
A
回答
1
你有没有考虑过使用SQLite数据库来存储这些字符串?
回答你的问题。是的,可以从远程服务器检索字符串,只要您在服务器端有适当的代码,以XML/JSON.etc的形式返回指定的字符串(比如使用ID)。
一旦你得到结果回来,解析响应得到的字符串。下面是一个示例代码:
private String _mStringURL = "http://yourserver.com/getString.php?string_id=<a unique id>&language=<languagecode>";
url = new URL(statusURL);
URLConnection connection;
connection = url.openConnection();
//Get data and check to see if everything was OK. Set time out to 10 secs.
HttpURLConnection httpConnection = (HttpURLConnection) connection;
httpConnection.setConnectTimeout(10*1000);
int responseCode = httpConnection.getResponseCode();
//Proceed if everything went OK in communication.
if(responseCode == HttpURLConnection.HTTP_OK){
InputStream in = httpConnection.getInputStream();
DocumentBuilderFactory dbf;
dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document dom = db.parse(in);
Element docEle = dom.getDocumentElement();
NodeList nl = docEle.getElementsByTagName("string");
//Your code to further parse and access teh data from return XML/JSON goes here.
}
0
为您的编程语言研究国际化解决方案。您可以简单地使用它来外化您的字符串,而不是用它来翻译您的应用程序。只需让程序从服务器上拉下.mo/.ini(或者系统使用的任何文件)即可。
请记住,这是有风险的。如果用户没有互联网连接,您的应用程序将完全无法使用。
你使用什么编程语言?我可以将你链接到一个教程。
相关问题
- 1. 从服务器检索字符串
- 2. 从远程服务器检索数据
- 3. 如何从远程服务器检索文件的目录?
- 4. 如何以检索的base64字符串从asp.net web服务
- 5. 使用rpcgen从远程服务器返回字符串
- 6. 如何从服务器资源管理器检索连接字符串
- 7. 从UDP服务器消息中检索字符串
- 8. 如何从远程服务器位置
- 9. 从Powershell中的远程服务器中检索文件
- 10. 从远程服务器C检索磁盘信息#
- 11. 如何从服务器检索数据
- 12. 如何从plist中检索字符串?
- 13. 如何从NSDate检索字符串?
- 14. 远程ORACLE服务器连接字符串
- 15. GoDaddy上的MySql连接字符串(远程服务器)
- 16. 远程服务器上的OLEDB连接字符串问题
- 17. 到远程服务器的SQL Server连接字符串
- 18. 获取远程服务器上的数组的字符串值
- 19. 连接字符串在远程服务器上不工作
- 20. 远程sql服务器连接字符串
- 21. 远程服务器的实体框架连接字符串
- 22. 远程数据库服务器的连接字符串
- 23. 从服务器检索
- 24. 如何从字符串的NSArray中检索字符串
- 25. 如何从字符串中检索子字符串?
- 26. 如何从字符串中检索重复的子字符串?
- 27. 检索字符串中的服务器响应代码
- 28. 检索服务总线事件集线器连接字符串
- 29. 如何从远程服务器进行远程登录 - c#
- 30. 无法从Web服务检索字符串数组
您要保存多少个字符串? – 2011-12-31 18:01:39
您可以将它作为一个XML并从网上解析它的值。 – Karthik 2011-12-31 18:02:40
你能给我一个这个教程的链接吗? – Leon 2011-12-31 18:04:11