Back to project page filemanager.
The source code is released under:
MIT License
If you think the Android project filemanager listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.binkery.app.filemanager; //from ww w . j a v a 2s . c o m import java.io.File; import java.util.ArrayList; import java.util.List; import android.annotation.SuppressLint; import android.annotation.TargetApi; import android.content.Context; import android.os.Build; import android.os.Environment; import android.os.StatFs; import android.os.storage.StorageManager; import com.binkery.app.filemanager.utils.Logs; import com.binkery.app.filemanager.utils.StringUtils; import com.binkery.app.filemanager.widget.SlidingMenuItem; import com.binkery.app.filemanager.widget.SlidingMenuView; public class SlidingMenuController { private static final String TAG = SlidingMenuController.class.getSimpleName(); private MainActivity mAct = null; private SlidingMenuView msmv = null; private List<String> sdcards = null; public SlidingMenuController(MainActivity activity, SlidingMenuView smv) { mAct = activity; msmv = smv; } public void setSelectedIndex(SlidingMenuItem.Menu menu) { mAct.getSlidingMenu().showContent(); switch (menu) { case ENTER: FragmentController.showEnterFragment(mAct); break; case SDCARD: FragmentController.showSdcardFragment(mAct); break; } } public void initMenuView() { sdcards = new ArrayList<String>(2); String EXTER_PATH = Environment.getExternalStorageDirectory().getAbsolutePath(); Logs.i(TAG, "EXTER_PATH = " + EXTER_PATH); StorageManager sm = (StorageManager) mAct.getSystemService(Context.STORAGE_SERVICE); try { String[] paths = (String[]) sm.getClass().getMethod("getVolumePaths", null) .invoke(sm, null); for(String path : paths){ Logs.i(TAG, "path = " + path); File file = new File(path); if(!file.exists() || !file.canRead()){ continue; } if(path != null && path.equals(EXTER_PATH)){ }else{ sdcards.add(path); } } } catch (Exception e) { } for(String path : sdcards){ Logs.i(TAG, "sdcard = " + path); File sdcard = new File(path); long total = sdcard.getTotalSpace(); long free = sdcard.getFreeSpace(); Logs.i(TAG, "space = " + StringUtils.formatFileSize(total) + "," + StringUtils.formatFileSize(free)); } File file = new File(EXTER_PATH); long total = file.getTotalSpace(); long free = file.getFreeSpace(); Logs.i(TAG, "space = " + StringUtils.formatFileSize(total) + "," + StringUtils.formatFileSize(free)); msmv.showSdcard(sdcards); } }