In my app I must let the user to choose where to save some files. It must choose from sd-card or internal memory.
I try to make some test directorys like this :
For Sd-card
File sdCard = Environment.getExternalStorageDirectory();
File dir = new File (sdCard.getAbsolutePath() + "/External dir");
dir.mkdirs();
For internal
File path2 = Environment.getDataDirectory();
File dir22 = new File (path2.getAbsolutePath() + "/Internal dir");
dir22.mkdirs();
- Only the 'External dir' is made. The 'Internal dir' does not. Also I have install on my phone 'OI File Manager' and also I can not make any dir on the internal storage
- My phone does not have any Sd-card at all. The code above does not give my any errors about no sd-card.
Also I try :
StatFs stat = new StatFs(Environment.getExternalStorageDirectory().getPath());
double sdAvailSize = (double)stat.getAvailableBlocks()*(double)stat.getBlockSize();
double mb= sdAvailSize / (1024*1024);
Log.w("sd-card",""+mb); //show me that i have 1240 mb on sd-card
and
File path = Environment.getDataDirectory();
StatFs stats = new StatFs(path.getPath());
int availableBlocks = stats.getAvailableBlocks();
int blockSizeInBytes = stats.getBlockSize();
int freeSpaceInBytes = availableBlocks * blockSizeInBytes;
double mb2= (availableBlocks*blockSizeInBytes)/(1024*1024);
Log.w("telephone",""+mb2); ///shows me 283 mb on phone
Why is that?