I know it is possible to use .getResources() to load XML data into a string array, but how do i do the opposite? I want to add an array to an XML file and save it.
我知道可以使用.getResources()将XML数据加载到字符串数组中,但我该怎么做?我想将一个数组添加到XML文件并保存。
2 个解决方案
#1
1
you can not write data in a xml file at runtime located in your res folder.
您不能在位于res文件夹中的运行时在xml文件中写入数据。
There are 5 options to save data at runtime
在运行时有5个选项可以保存数据
1) Shared Preferences: Store private primitive data in key-value pairs. 2) Internal Storage: Store private data on the device memory. 3) External Storage: Store public data on the shared external storage. 4) SQLite Databases: Store structured data in a private database. 5) Network Connection: Store data on the web with your own network server.
1)共享首选项:将私有原始数据存储在键值对中。 2)内部存储:将私有数据存储在设备内存中。 3)外部存储:将公共数据存储在共享外部存储上。 4)SQLite数据库:将结构化数据存储在私有数据库中。 5)网络连接:使用您自己的网络服务器将数据存储在Web上。
Shared Preferences is used when you have small data. Internal Storage or External Storage can used for saving files like image, text file etc. SQLite Database can be used to store contact numbers, area name and Network Connection is used when you have client server situation like for data entry application.
当您拥有较小的数据时,将使用共享首选项。内部存储或外部存储可用于保存文件,如图像,文本文件等.SQLite数据库可用于存储联系人号码,区域名称和网络连接用于客户端服务器情况,如数据输入应用程序。
Read more here http://developer.android.com/guide/topics/data/data-storage.html
在此处阅读更多信息http://developer.android.com/guide/topics/data/data-storage.html
#2
0
What you want isn't possible but I would recommend looking at this question. SharedPreferences
is probably what you're looking for but depending on your goals you could simply save to a text file.
你想要什么是不可能的,但我建议看看这个问题。 SharedPreferences可能是您正在寻找的,但根据您的目标,您可以简单地保存到文本文件。
#1
1
you can not write data in a xml file at runtime located in your res folder.
您不能在位于res文件夹中的运行时在xml文件中写入数据。
There are 5 options to save data at runtime
在运行时有5个选项可以保存数据
1) Shared Preferences: Store private primitive data in key-value pairs. 2) Internal Storage: Store private data on the device memory. 3) External Storage: Store public data on the shared external storage. 4) SQLite Databases: Store structured data in a private database. 5) Network Connection: Store data on the web with your own network server.
1)共享首选项:将私有原始数据存储在键值对中。 2)内部存储:将私有数据存储在设备内存中。 3)外部存储:将公共数据存储在共享外部存储上。 4)SQLite数据库:将结构化数据存储在私有数据库中。 5)网络连接:使用您自己的网络服务器将数据存储在Web上。
Shared Preferences is used when you have small data. Internal Storage or External Storage can used for saving files like image, text file etc. SQLite Database can be used to store contact numbers, area name and Network Connection is used when you have client server situation like for data entry application.
当您拥有较小的数据时,将使用共享首选项。内部存储或外部存储可用于保存文件,如图像,文本文件等.SQLite数据库可用于存储联系人号码,区域名称和网络连接用于客户端服务器情况,如数据输入应用程序。
Read more here http://developer.android.com/guide/topics/data/data-storage.html
在此处阅读更多信息http://developer.android.com/guide/topics/data/data-storage.html
#2
0
What you want isn't possible but I would recommend looking at this question. SharedPreferences
is probably what you're looking for but depending on your goals you could simply save to a text file.
你想要什么是不可能的,但我建议看看这个问题。 SharedPreferences可能是您正在寻找的,但根据您的目标,您可以简单地保存到文本文件。