How to access External Micro SD card of the phone?

前端 未结 6 1565
借酒劲吻你
借酒劲吻你 2020-12-03 02:00

Does anyone know how can I get SD card of the phone?

I know that someone will tell me its getExternalStorageDirectory() or Environment.getExterna

6条回答
  •  失恋的感觉
    2020-12-03 02:48

    You can get the path like the following way.....

    File sdCardRoot = Environment.getExternalStorageDirectory();
            PATH = sdCardRoot.toString();
    

    If the path not exist, then you have to make the path by mkdir().....

    private File getTempFile(Context context) {
            final File path = new File(Environment.getExternalStorageDirectory(),
                    context.getPackageName());
            if (!path.exists()) {
                path.mkdir();
            }
            return new File(path, "new.png");
        }
    

    The above function will return the file...

提交回复
热议问题