I would like to get a path to public storage of my android device. I have two applications. One is writing some log files and the other one is used to read them (for this reason I cant use application private storage). I would like to know if there is a method, that will give me path of the "public space" of my device where I can easly create and read files.
This solution is not what I am looking for:
http://developer.android.com/guide/topics/data/data-storage.html#filesInternal
Neither is that:
How to get the internal and external sdcard path in android
Is there a easy solution for my problem? Is the external public storage what I am looking for?
http://developer.android.com/guide/topics/data/data-storage.html#filesExternal
The problem is that when I run application on my device everything is ok, but then when I run it on device where there is no memory card, it is not working. So I would like to use external public storage, that is not a memory card...
My code below doesn't work (it doesn't save the file). When I choose directory that is directly in Environment.getExternalStorageDirectory().getAbsolutePath(), it work... What I do wrong? :
transient private final String DIRECTORY = "/Android/data/com.aaa.bbb.ccc/files/";
public void writeLog()
{
Calendar calendar = setDate();
File dir = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + DIRECTORY);
if(!dir.exists())
dir.mkdir();
File file = new File (dir, "log_" + calendar.get(Calendar.YEAR) + "_"
+ ((calendar.get(Calendar.MONTH))+1) + "_"
+ calendar.get(Calendar.DAY_OF_MONTH)
+ ".dta");
...
}
UPDATE:
Why this code works:
File dir = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/Dir1/");
if(!dir.exists())
dir.mkdir();
And this doesn't
File dir = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/Dir1/Dir2/Dir3/");
if(!dir.exists())
dir.mkdir();