Unable to save mp3 file in some specific device [closed]

风格不统一 提交于 2019-12-13 10:56:50

问题


In my project I put this code to copy mp3 file here writefile is the function that copies file.

code is correctly working on devices except Moto G with Android 5.1

p_name = mp_name.concat(".mp3");
        InputStream inputStream = null;

        try {
            inputStream = getResources().openRawResource(mpTrake[id]);
            byte[] reader = new byte[inputStream.available()];
            while (inputStream.read(reader) != -1) {
            }
            writefile(reader, "/sdcard/" + mp_name);
            Log.i("setring", "success");
        } catch (IOException e) {
            Log.i("setring", e.getMessage());
        } finally {
            if (inputStream != null) {
                try {
                    inputStream.close();
                } catch (IOException e) {
                    Log.i("setring", e.getMessage());
                }
            }
        }

回答1:


May be is file path problem If you have set path to \sdcard\ but phone has not inserted sd card then you get errors



来源:https://stackoverflow.com/questions/36057808/unable-to-save-mp3-file-in-some-specific-device

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!