How to access /storage/emulated/0/

前端 未结 16 2253
被撕碎了的回忆
被撕碎了的回忆 2020-12-13 01:53

I have written a code to record audio and save it to below file location.

private String getFilename() {
    String          


        
相关标签:
16条回答
  • 2020-12-13 02:52

    Plug in your device and run adb shell which will get you a command shell on your device. You don't have permission to read /storage/emulated/ but since you know it's in subdirectory 0 just go cd /storage/emulated/0 and you will be able to look around and interact as aspected.

    Note: you can use adb wirelessly as well

    0 讨论(0)
  • 2020-12-13 02:52

    Android recommends that you call Environment.getExternalStorageDirectory.getPath() instead of hardcoding /sdcard/ in path name. This returns the primary shared/external storage directory. So, if storage is emulated, this will return /storage/emulated/0. If you explore the device storage with a file explorer, the said directory will be /mnt/sdcard (confirmed on Xperia Z2 running Android 6).

    0 讨论(0)
  • 2020-12-13 02:58

    Try This

    private String getFilename() {
        String filepath = Environment.getExternalStorageDirectory().getPath();
        File file = new File(filepath + "/AudioRecorder" );
        if (!file.exists()) {
            file.mkdirs();
        }
        return (file.getAbsolutePath() + "/" + System.currentTimeMillis() + ".mp4");
    }
    
    0 讨论(0)
  • 2020-12-13 02:59

    if you are using Android device monitor and android emulator : I have accessed following way: Data/Media/0/

    0 讨论(0)
提交回复
热议问题