title: Send byte array from ms sql database to android through webservice
body: <p>I have a C# web service that gets data from a MS SQL database and sends it to an Android device as a XML string.</p>
  
  <p>I then parse the XML in Android and store the data in an Android database</p>
  
  <p>This works fine for all string and integer data but I can't get a byte array (which is used to store an image) to work in same way</p>
  
  <p>My C# code to add the byte array to XML looks like this:</p>
  
  <pre><code>XmlElement ImageStored = (XmlElement)StockItem.AppendChild(doc.CreateElement("ImageStored"));
  
  ImageStored.InnerText = Convert.ToBase64String(stockItem.ImageStored);
  </code></pre>
  
  <p>And in Android i have tried this:</p>
  
  <pre><code>NodeList nImageStored = doc.getElementsByTagName("ImageStored");
  
  for(int i = 0; i &lt; nImageStored.getLength(); i++)
  {
     byte[] pImageStored =  nImageStored.item(i).getFirstChild().getNodeValue().trim().getBytes();
     //save byte[] in database
  }
  </code></pre>
  
  <p>This is not giving me any errors and does save something in the database, but when it comes to displaying the image nothing appears.</p>
  
  <p>Any help on how to get this working would be great. This is the first time I have tried working with C# and Android together so forgive me if I am being stupid.</p>
  
  <p>Thanks!</p>