2013年7月22日星期一

android how to get the fuselage storage location

External memory card can be used Environment.getExternalStorageDirectory () to obtain,
but the body how to get it stored?


------ Solution ------------------------------------ --------
body position can write your own death, which is based linux systems, for example you want to navigate to their own applications on the / data / data / com.abc
----- - Solution --------------------------------------------
< img src = "http://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/003/onion/17.gif" alt = "" />

 getExternalStoragePublicDirectory 
This is an internal

External words
StorageVolume this
------ Solution --------------------------------- -----------
http://developer.android.com/guide/topics/data/data-storage.html # filesInternal can refer to if you do not know want to answer
------ For reference only ---------------------------------- -----
write die not,
because to deal with a variety of machines,
possible different paths
------ For reference only ------------------------------ ---------

next check, getExternalStoragePublicDirectory point is to get shared storage, such as music, pictures, etc., right
StorageVolume did not find what it is?
------ For reference only -------------------------- -------------
looking for a long time and found that the memory can be obtained through reflection list
but do not know which is the built-in memory
 StorageManager storageManager = (StorageManager) getSystemService (Context.STORAGE_SERVICE);
try {
Class  [] ParamClasses = {};
Method getVolumePathsMethod = StorageManager.class.getMethod ("getVolumePaths", paramClasses);
getVolumePathsMethod.setAccessible (true);
Object [] params = {};
Object invoke = getVolumePathsMethod.invoke (storageManager, params);
for (int i = 0; i <((String []) invoke). length; i + +) {
System.out.println (((String []) invoke) [i]);
} 
} Catch (NoSuchMethodException e1) { e1.printStackTrace (); } Catch (IllegalArgumentException e) { e.printStackTrace (); } Catch (IllegalAccessException e) { e.printStackTrace (); } Catch (InvocationTargetException e) { e.printStackTrace (); }

------ For reference only --------------------------------- ------

right, StorageVolume I found, but it is being hidden
------ For reference only ----------- ----------------------------

0 Built
1 External Results posted it



------ For reference only ---------------------------------------
can reflect this approach

getVolumePaths get pass
------ For reference only ------------------------------ ---------
0 Built
1 External

this argument does not necessarily
For example, my phone can be set to the external memory card as the default memory card
so 0 is the external

Oh
Thank
------ For reference only -------------------------------- -------
mark about

没有评论:

发表评论