Android: Save data to internal memory using Downlo

2019-08-24 07:05发布

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?

2条回答
倾城 Initia
2楼-- · 2019-08-24 07:59

add

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

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

查看更多
时光不老,我们不散
3楼-- · 2019-08-24 08:04

try this

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

and

if (!testDirectory.exists()) {
    testDirectory.mkdirs();
        }
查看更多
登录 后发表回答