如何保存?它是保存在什么地方?

解决方案 »

  1.   

    Android提供个很小内存的udisk,类似缓存的
      

  2.   

    udisk的大小可以划分数据分区的
      

  3.   


    内存好像不能保存吧,一般android内存有100多M。 
      

  4.   

    Android实现下载图片并保存到SD卡中
      

  5.   

    得到网络上的图片,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;
        }