Android 保存图片 如何保存?它是保存在什么地方? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Android提供个很小内存的udisk,类似缓存的 udisk的大小可以划分数据分区的 内存好像不能保存吧,一般android内存有100多M。 Android实现下载图片并保存到SD卡中 得到网络上的图片,url就是图片的地址了 public Bitmap getPhoto(String url){ URL bitmapURL = null; Bitmap photo = null; HttpURLConnection conn = null; try { bitmapURL = new URL(url); } catch (MalformedURLException e) { } try { conn = (HttpURLConnection)bitmapURL.openConnection(); conn.connect(); InputStream is = conn.getInputStream(); photo = BitmapFactory.decodeStream(is); is.close(); } catch (IOException e) { e.printStackTrace(); } return photo; }然后再将图片保存到SD卡上bitmap就是上面那个函数得到的图片name就是要保存的函数名因为是保存到SD卡,最好判断是否转入了SD卡~ private boolean storeImageToFile(Bitmap bitmap, String name){ if(bitmap == null){ return false; } File file = null; RandomAccessFile accessFile = null; String path = 路径名"; ByteArrayOutputStream steam = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG, 100, steam); byte[] buffer = steam.toByteArray(); try { path = path + "/" + name + ".png"; file = new File(path); accessFile = new RandomAccessFile(file, "rw"); accessFile.write(buffer); } catch (Exception e) { return false; } try { steam.close(); accessFile.close(); } catch (IOException e) { return false; } return true; } 详细说一下我的问题,希望大家帮帮我 GridView getview 重复调用 android小问题,求各位大虾解救啊!!!! dialog 在按home键的时候不消失 什么时候需要使用Handler? 获取手机支持的视频编码方式和视频格式 menu菜单为啥不响应? 请问Android项目中的数据库查询语句如何写 2013年度【博客之星评选活动】正在进行中,希望大家支持下,十分感谢! android studio webview缓存问题 大家帮我看看这个getResult对象咋得不到数值啊 如何获取手机的重力感应数据
内存好像不能保存吧,一般android内存有100多M。
public Bitmap getPhoto(String url){
URL bitmapURL = null;
Bitmap photo = null;
HttpURLConnection conn = null;
try {
bitmapURL = new URL(url);
} catch (MalformedURLException e) {
}
try {
conn = (HttpURLConnection)bitmapURL.openConnection();
conn.connect();
InputStream is = conn.getInputStream();
photo = BitmapFactory.decodeStream(is);
is.close();
} catch (IOException e) {
e.printStackTrace();
}
return photo;
}然后再将图片保存到SD卡上
bitmap就是上面那个函数得到的图片
name就是要保存的函数名
因为是保存到SD卡,最好判断是否转入了SD卡~
private boolean storeImageToFile(Bitmap bitmap, String name){
if(bitmap == null){
return false;
}
File file = null;
RandomAccessFile accessFile = null;
String path = 路径名";
ByteArrayOutputStream steam = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, steam);
byte[] buffer = steam.toByteArray(); try {
path = path + "/" + name + ".png";
file = new File(path);
accessFile = new RandomAccessFile(file, "rw");
accessFile.write(buffer);
} catch (Exception e) {
return false;
}
try {
steam.close();
accessFile.close();
} catch (IOException e) {
return false;
}
return true;
}