为什么我的图像路径在所有安卓手机上都不同

  • 本文关键字:手机 图像 路径 android
  • 更新时间 :
  • 英文 :

我想将所有手机

的图像保存在相同的路径中。这是我的路径代码

if(!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)
{
  File fil = new File(c.getFilesDir().getPath()+File.separator+"HMS_BARCODE");
  fil.mkdirs();
     //and i have created for both external and internal
     //here r the paths coming from mobiles
  String imageInSD = "/storage/sdcard0/HMS_BARCODE/"+ Barcode +".PNG";
  String imageInSD1 = "/storage/emulated/0/HMS_BARCODE/"+ Barcode +".PNG";
}

尝试使用

Environment.getExternalStorageDirectory()
如果您有可以使用的

Context

context.getExternalFilesDir(null).getAbsolutePath();

您将拥有存储路径:/Android/data/软件包名称/files/

文档在这里

最新更新