简体   繁体   English

编写和读取XML输入

[英]writing and reading input to xml

I am new to Android development and have been struggling with a problem. 我是Android开发的新手,一直在努力解决问题。 I have been trying to learn how to save user inputs to file. 我一直在尝试学习如何将用户输入保存到文件中。 I have asked a similar answer and ended up figuring out a solution although it didn't work out the way I want. 我问了一个类似的答案,并最终想出了一个解决方案,尽管它无法解决我想要的方式。 I have been searching high and low about how to write files to xml. 我一直在搜寻有关如何将文件写入xml的高低要求。 I would to have a user be able to save, add, retreive, and be able to remove items from an XML file. 我希望用户能够保存,添加,检索以及能够从XML文件中删除项目。 I think the problem I am having as far as learning this is I'm not sure what the processes are call to properly look for a solution. 我认为,就我所了解的问题而言,我不确定要正确寻找解决方案需要调用哪些流程。 This isn't for school work, I'm not looking for anyone to write up some code for me. 这不是为了学校的工作,我不是在寻找任何人为我编写一些代码。 What I am hoping for is proper terminology, maybe a link to some helpful information and such. 我希望使用适当的术语,也许是一些有用信息的链接等。 I believe this process is called parsing, and you can add to XML through appending, not sure about much after this. 我相信此过程称为解析,您可以通过追加将其添加到XML,此后还不确定。 Thank you in advance to anyone who can offer assistance. 预先感谢任何可以提供帮助的人。

To have the XML always available for the app you should put it in the "assets" folder. 要使XML对于该应用程序始终可用,应将其放在“资产”文件夹中。 You should copy-paste the xml file to modify it, to ensure the file won't be corrupted afterwards. 您应该复制粘贴xml文件以对其进行修改,以确保此后该文件不会被损坏。

First you have to copy the xml to the sdcard (preferably to a folder with your app name as folder name), you can use this to learn how to copy a file. 首先,您必须将xml复制到sdcard(最好复制到以您的应用程序名称作为文件夹名称的文件夹),然后您可以使用来学习如何复制文件。 After you have done that you can use the JDOM Parser to modify that xml file. 完成之后,可以使用JDOM Parser修改该xml文件。

Put the xml after the modification back in the assets folder. 将修改后的xml重新放到资产文件夹中。

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

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