I am trying to store data on an SD card, according to the guide here I have to use getExternalFilesDir() (API level 8), I would really like to do this, but by calling File directory = context.getExternalFilesDir(null); keeps returning null , I use my main action as a context.
Then I tried to revert to using File dir = Environment.getExternalStorageDirectory(); , it returned the SD root correctly, but apparently I was unable to create the proposed directory "/ Android / data / package_name / files /":
File root = Environment.getExternalStorageDirectory(); File dir = new File(root, GlobalConstants.EXTERNAL_SAVE_DIR); boolean canCreate = dir.mkdirs();
In this code, canCreate is false (EXTERNAL_SAVE_DIR explicitly / Android / data / package _name / files /).
Is there anything that I am missing, maybe I should ask for permission to manifest (I did not find anything)? I read getExternalFilesDir() has an error in which the content is deleted when the application is updated, I do not care, and I would prefer to use it instead of another, as I try to match API 8, and I like the idea of ββhandling the directory name for me.
Any idea?
android
capitano666
source share