关于 /mnt/sdcard 和 /sdcard 有什么区别?

关于 /mnt/sdcard 和 /sdcard 有什么区别?

问题描述:

我想把一个 bitmap保存到图片目录中。以下是代码:

File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);

            File file = new File(path, "test1.PNG");
            try { 
                   path.mkdirs();
                   OutputStream out = new FileOutputStream(file);
                   mBitmap.compress(Bitmap.CompressFormat.PNG, 90, out);
                   out.flush();
                   out.close();

            } catch (Exception e) {
                   e.printStackTrace();
                   Log.w("ExternalStorage", "Error writing " + file, e);
            }

程序执行在OutputStream out = new FileOutputStream(file);这句语句时出现问题。我使用调试器,然后全路径中返回mnt/sdcard/Pictures/test1.PNG。是mnt/的问题吗?为什么不能获得OutputStream out = new FileOutputStream(file);?在文件目录中我只能看见sdcard/
谢谢大家指导!

/mnt 目录,熟悉linux的人都清楚,linux默认挂载外部设备都会挂到这个目录下面去,如将sd卡挂载上去后,会生成一个/mnt/sdcard 目录。
/sdcard 目录,这是一个软链接(相当于windows的文件夹的快捷方式),链接到/mnt/sdcard 目录,即这个目录的内容就是sdcard的内容。

 String filePath = "/sdcard/yourfile.txt";

 FileOutputStream os = null;
 os = new FileOutputStream(filePath); 
 os.write(write it to file);
 os.close();

使用这个方法。