Android Utililty Methods XML Serializer Write

List of utility methods to do XML Serializer Write

Description

The list of methods to do XML Serializer Write are organized into topic(s).

Method

voidmultipleTexts(final XmlSerializer serializer, final String prefix, final String... tagAndText)
Insert pairs of attribute-less tags and enclosed texts in a XML serializer output
for (int i = 0; i < tagAndText.length; i += 2) {
    simpleText(serializer, prefix, tagAndText[i], tagAndText[i + 1]);
voidsimpleText(final XmlSerializer serializer, final String prefix, final String tag, final String text)
Insert an attribute-less tag with enclosed text in a XML serializer output.
if (text != null) {
    serializer.startTag(prefix, tag);
    serializer.text(text);
    serializer.endTag(prefix, tag);
voidtextTag(XmlSerializer xml, String namespace, String name, Object text)
text Tag
xml.startTag(namespace, name);
if (text != null)
    xml.text(text.toString());
xml.endTag(namespace, name);
voidwriteBitmapAttribute(XmlSerializer out, String name, Bitmap value)
write Bitmap Attribute
if (value != null) {
    final ByteArrayOutputStream os = new ByteArrayOutputStream();
    value.compress(CompressFormat.PNG, 90, os);
    writeByteArrayAttribute(out, name, os.toByteArray());
voidwriteBitmapAttribute(XmlSerializer out, String name, Bitmap value)
write Bitmap Attribute
if (value != null) {
    final ByteArrayOutputStream os = new ByteArrayOutputStream();
    value.compress(CompressFormat.PNG, 90, os);
    writeByteArrayAttribute(out, name, os.toByteArray());
voidwriteBooleanAttribute(XmlSerializer out, String name, boolean value)
write Boolean Attribute
out.attribute(null, name, Boolean.toString(value));
voidwriteBooleanAttribute(XmlSerializer out, String name, boolean value)
write Boolean Attribute
out.attribute(null, name, Boolean.toString(value));
voidwriteByteArrayAttribute(XmlSerializer out, String name, byte[] value)
write Byte Array Attribute
if (value != null) {
    out.attribute(null, name,
            Base64.encodeToString(value, Base64.DEFAULT));
voidwriteByteArrayXml(byte[] val, String name, XmlSerializer out)
Flatten a byte[] into an XmlSerializer.
if (val == null) {
    out.startTag(null, "null");
    out.endTag(null, "null");
    return;
out.startTag(null, "byte-array");
if (name != null) {
    out.attribute(null, "name", name);
...
voidwriteByteArrayXml(byte[] val, String name, XmlSerializer out)
Flatten a byte[] into an XmlSerializer.
if (val == null) {
    out.startTag(null, "null");
    out.endTag(null, "null");
    return;
out.startTag(null, "byte-array");
if (name != null) {
    out.attribute(null, "name", name);
...