I have the same problem like in Android, delete files in my data directory?
But it is not working for me.
String sourcefile = getFilesDir().toString() + "/aaa.jpk";
File file = new File(sourcefile);
file.delete();
That should be the easiest way to delete that file but somehow I can't do it. The permissions are added to android manifest:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
so that not the problem. That string is leads me to file :
data/data/com.example.program/files/aaa.jpk
Where is my problem actually? I can't figure that out.
Code for downloading file:
dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
Uri resource = Uri.parse("http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml");
DownloadManager.Request request = new DownloadManager.Request(resource);
request.setAllowedNetworkTypes(Request.NETWORK_MOBILE | Request.NETWORK_WIFI);
request.setDestinationInExternalFilesDir(getApplicationContext(), null, "aaa");
request.setAllowedOverRoaming(false);
request.setTitle("a.xml");
dm.enqueue(request);
Never use concatenation to create a path. Use
File file=new File(getFilesDir(), "aaa.jpk");
and see if that helps. Note that your permissions are irrelevant here, as you are working with internal storage, not external storage.