Behavior of Create directory on SD card or internal memory
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();
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?
链接地址: http://www.djcxy.com/p/66910.html上一篇: 应用程序在不同的设备类型上安装大小相同
下一篇: 在SD卡或内存上创建目录的行为