是否可以从SD卡加载strings.xml而不是应用程序res/values/...在网络上搜索,但没有找到任何教程。我的想法是将xml下载到sd卡,然后将字符串元素保存到数组中。从SD卡加载strings.xml到应用程序android
public void stringsxml(){
File file = new File(Environment.getExternalStorageDirectory()
+ ".strings.xml");
StringBuilder contents = new StringBuilder();
try {
//use buffering, reading one line at a time
//FileReader always assumes default encoding is OK!
BufferedReader input = new BufferedReader(new FileReader(file));
try {
String line = null; //not declared within while loop
/*
* readLine is a bit quirky :
* it returns the content of a line MINUS the newline.
* it returns null only for the END of the stream.
* it returns an empty String if two newlines appear in a row.
*/
while ((line = input.readLine()) != null){
contents.append(line);
contents.append(System.getProperty("line.separator"));
}
}
finally {
input.close();
}
}
catch (IOException ex){
ex.printStackTrace();
}
String data= contents.toString();
}
因此而不是使用strings.xml中,我们可以存储的语言为.sqllite数据库和服务器 – Dimitri
是更新数据库,但你不能把它的资源。 – Szymon