我正在使用此代码保存图像我不确定它是否正确
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;
}
有人可以告诉我他是否正确。我希望恢复已保存的图像并在列表视图中显示我不知道如果有人知道如何做到这一点