问题
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