android - How to read an existing xml file from sdcard and add new data into it -


I just want to read xml file from sdcard and want to add some new data. Then I have to write it in sdcard. How can I implement it Any help would be highly appreciated.

Writing Reading is XML file sample. And you can get them using lots of them. However, two important sections of the XmlSerializer and XmlPullParser . A simple XmlSerializer example: -

  public static string CreateXMLString (throws IllegalArgumentException, IllegalStateException, IOException {XmlSerializer XmlSerializer = Xml.newSerializer ()); Stringworld author = new stringwriter (); XmlSerializer.setOutput (author); // Start Document xmlSerializer.startDocument ("UTF-8", true); XmlSerializer.setFeature ("http://xmlpull.org/v1/doc/features.html#indent-output", true); // Open Tags & lt; File & gt; XmlSerializer.startTag ("", "File"); XmlSerializer tempXml = Xml.newSerializer (); Stringwriters temputer = new stringwriter (); XmlSerializer.startTag ("", "Something"); XmlSerializer.attribute ("", "ID", "000001"); XmlSerializer.startTag ("", "name"); XmlSerializer.text ("Company"); XmlSerializer.endTag ("", "name"); XmlSerializer.endTag ("", "Something"); // End tag & lt; File & gt; XmlSerializer.endTag ("", "File"); XmlSerializer.endDocument (); Return Author Tothing (); }   

Similarly you can get XmlPullParser together for one. Since you want to read / write files in sdcard, so Environment.getExternalStorageDirectory () do not forget to call. GetAbsolutePath () to obtain the path to the external storage directory See a simple example.

Be sure to add the following line to your manifest file, without any action.

If you update your question you do not get it working with the specific problem

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -