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 Similarly you can get XmlPullParser together for one. Since you want to read / write files in sdcard, so 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 XmlSerializer and
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 (); }
Environment.getExternalStorageDirectory () do not forget to call. GetAbsolutePath () to obtain the path to the external storage directory See a simple example.
Comments
Post a Comment