在android中保存获取图像e找到路径

时间:2014-08-24 17:08:22

标签: android

我使用这些方法进行保存并获取图像

public void saveImage(Context context, Bitmap b, String name) {   
   FileOutputStream out;
     try {
         out = context.openFileOutput(name, Context.MODE_PRIVATE);
         b.compress(Bitmap.CompressFormat.JPEG, 90, out);
         out.close();

     } catch (Exception e) {
         e.printStackTrace();
     }
 }

这是getImage

public Bitmap getImageBitmap(Context context, String name) {
    try {
        FileInputStream fis = context.openFileInput(name);
        Bitmap b = BitmapFactory.decodeStream(fis);
        fis.close();

        return b;
    } catch (Exception e) {
    }
    return null;
}

这种方式对我来说很好,但现在我需要在服务器上传图像,为此我需要图像的路径。 你知道如何在不创建新图像的情况下找到它吗?

1 个答案:

答案 0 :(得分:0)

Call getFileStreamPath(),其中包含您与openFileInput()openFileOutput()一起使用的文件名。