androidimagefileoutputstream

Android Writing/Reading Picture To Internal Storage


I faced a problem saving and loading Pictures on android (Picture object). Here is my code for writing to Internal Storage (i am not sure if it works properly):

FileOutputStream fos = null;
Picture l0 = new Picture();
fos = openFileOutput("layer0", Context.MODE_PRIVATE);
InputStream is = new ByteArrayInputStream(layer0.getBytes());
SVG svg = SVGParser.getSVGFromInputStream(is);
l0 = svg.getPicture();
                
l0.writeToStream(fos);
fos.close();

How can I read this image back?


Solution

  • Use the function createFromStream

    Something like:

    Picture myPic = Picture.createFromStream(openFileInput("layer0"));