title: How to write a Bitmap out to a XML file
body: <p>Might sound crazy, but it's what I need to do.  I want to take a Bitmap object and use the XMLPullParser/XmlSerializer to write this to a flat file.  Obviously I will need to read the XML tag back into a Bitmap object.</p>
  
  <p>I have tried various things, similar to how I write and read Bitmaps from a database.</p>
  
  <pre><code>            Bitmap bitmap = ((BitmapDrawable) icon).getBitmap();                
              ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); 
              bitmap.compress(CompressFormat.PNG, 0, outputStream); 
              byte[] bitmapByte = outputStream.toByteArray(); 
  </code></pre>
  
  <p>Where I get lost is once I write this out to my XML file as a String, I can never get it converted back properly.  Any pointers is appreciated.</p>
  
  <p>Edit:
  I want to provide a little more information. I am writing out a good deal of XML data for a backup purpose, so loading or writing time is of no concern.  This is not a main source of the data (main source is a SQLite database).  I do not want to have to write out a couple of very small (48x48pixel) images as well if I can help it.</p>
  
  <p>I am reading in my XML using the XMLPullParser, which reads a String:</p>
  
  <pre><code>if (name.equalsIgnoreCase("someXmlTag")){
  String someString = parser.nextText();
  </code></pre>
  
  <p>I am writing out my XML using the XmlSerializer, which writes a String:</p>
  
  <pre><code>            XmlSerializer serializer = Xml.newSerializer();
          StringWriter writer = new StringWriter();
              serializer.setOutput(writer);
              serializer.startDocument("UTF-8", true);
              serializer.startTag("", "someTag");
                             serializer.text(someString);
  </code></pre>
  
  <p>So somehow I have to turn my Bitmap into a String and then turn that String back into a Bitmap. I will do some searches on Base64 to see if I get any good examples.</p>