Recovers image saved in internal memory

I am saving my image to internal memory using this code

public String baixarImagem(String urlC, String nomeImagem) throws MalformedURLException {
    URL url = new URL(urlC);

    InputStream input = null;
    FileOutputStream output = null;

    try {
        String outputName = nomeImagem + ".jpg";

        input = url.openConnection().getInputStream();
        output = context.openFileOutput(outputName, Context.MODE_PRIVATE);

        int read;
        byte[] data = new byte[1024];
        while ((read = input.read(data)) != -1)
            output.write(data, 0, read);

        return outputName;

    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        try {
            if (output != null)
                output.close();

            if (input != null)
                input.close();

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    return null;
}

More I do not know how to recover this saved image, I do not even know if this code is saving even the image. Can someone tell me if this code is right and show me how to retrieve the image

Author: Ilgner de Oliveira, 2014-12-17

1 answers

Do something like this:

String path = context.getFilesDir().toString();
String fileName = "nome_imagem.jpg";

Bitmap bMap = BitmapFactory.decodeFile(path + "/" + fileName);

With Bitmap you can display where needed.

 1
Author: Paulo Rodrigues, 2014-12-18 11:24:18