Android: Save data to internal memory using Download

独自空忆成欢 提交于 2019-12-12 03:39:17

问题


I am downloading file from a server in Android using the DownloadManager class. I want to store this file in the internal memory of the device. I tried to use .setDestinationInExternalPublicDir(Environment.getExternalStorageDirectory() +"/Android/data/xxx.xxx.xxx/files/") as mentioned here, but it is not working. How to solve my problem?


回答1:


add

   <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

to manifest.xml and create "/Android/data/xxx.xxx.xxx/files/" path




回答2:


try this

File testDirectory = new File(Environment.getExternalStorageDirectory() +"/Android/data/xxx.xxx.xxx/files/");

and

if (!testDirectory.exists()) {
    testDirectory.mkdirs();
        }


来源:https://stackoverflow.com/questions/11341782/android-save-data-to-internal-memory-using-download

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