Sunday, March 2, 2014

Methods seek to obtain external SDcard path


Recently doing a file manager, you need to use the path sdcard, because different machine mount path is not the same, so the only dynamic acquisition,
The current practice is to broadcast monitoring system, but if you open the file manager before had mounted the sdcard, this is also not receive the broadcast path, beg a good way.<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
I am also engaged in such a program, you can try the following code
 
private boolean IsHaveSdCard ()
{/ / Determine whether there sdcard
if (Environment.getExternalStorageState (). equals (/ / to normal operation
Environment.MEDIA_MOUNTED))
{
return true;
}
else if (Environment.getExternalStorageState (). equals (/ / connection on the computer
Environment.MEDIA_SHARED))
{/ / Error write your own class, Error.MsgBox display a dialog box
Error.MsgBox (mContext, "the implementation of this software, please do not connect your phone on the computer", "Error");

}
else
{/ / MsgBox msg = new MsgBox ("no available SDCard, the program failed to initialize", "Error", 0,1);
Error.MsgBox (mContext, "no available SDCard, the program failed to initialize", "Error");

}

return false;
}

Reply:
Upstairs determine whether there sd card, sd card to get the following path
SDCardRoot = Environment.getExternalStorageDirectory ()
. GetAbsolutePath () + File.separator
Reply:
Provide an idea, you can get the mount point
by STORAGE_SERVICEmStorageManager = (StorageManager) getSystemService (Context.STORAGE_SERVICE);
storageVolumes = mStorageManager.getVolumeList ();

No comments:

Post a Comment