2010년 12월 30일 목요일

[Android Course][English][Theme] - Sdcard related API




1. Sdcard Path
: 'Sdcard' path '/ sdcard /' and so can not be used.
'android phone' every little 'sdcard root path' may be different.

ex) sdcard/...
ex) mnt/sdcard/...
....ETC

Therefore, 'sdcard root path' to access the API must be used as follows.
=> File path = Environment.getExternalStorageDirectory();


2. Check Sdcard capacity


: Sdcard Data Write and the other when working on, to check if the pre-dose program, maybe better.

File sdcard_path = Environment.getExternalStorageDirectory();
StatFs stat = new StatFs(sdcard_path.getPath());
long blockSize = stat.getBlockSize();
long totalBlocks = stat.getBlockCount();
long availableBlocks = stat.getAvailableBlocks();

- Total capacity
long Total_Size = totalBlocks * blockSize;
- Available capacity
long Available_Size = availableBlocks * blockSize;
- Capacity is being used
long Used_Size = Total_Size * Available_Size;
3. Sdcard Permission Setting
: Sdcard needed for the Data Write operation is set.
- AndroidManifest.xml
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>


In addition, inquiries, or questions, please contact us.
(joonryang@gmail.com)

댓글 없음:

댓글 쓰기