Aman Verma Aman Verma - 5 months ago 59
Android Question

How to save SVG in internal Storage And retrieve it and set it to ImageView?

I need to save the .svg in the Internal storage of android application and retrieve it and set it to the ImageView.

I am not able to save the .svg file. i am using this method -

File cacheDir = ctx.getCacheDir();
f = new File(cacheDir, name + ".png");

try {
InputStream in = new;
mIcon = BitmapFactory.decodeStream(in);

try {

FileOutputStream out = new FileOutputStream(
100, out);

return f;

} catch (FileNotFoundException e) {

return null;
} catch (IOException e) {

return null;

} catch (Exception e) {

return null;

Gut Gut
Answer Source

Why are you decoding SVG into bitmap ? I'm no sure it is possible.

But if you wannna save SVG file in storage, just copy you input stream into output stream.

Simple java solution :

byte[] buffer = new byte[1024];
int len;
while ((len = != -1) {
    out.write(buffer, 0, len);

or with IOUtils

If you want to display your SVG file, look at

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download