android - Get storage type of local path -
if have paths following:
/storage/emulated/0/...
/storage/usbdrivea/...
/sdcard/...
i have following questions:
- how find out storage located on? (usb stick, external storage, internal storage)
- how find out type are? (primary storage (i have direct r/w access), secondary storage (on android >=4.4, don't have direct w access , need acquire right through
storage access framework
if need it)) - how find out root path is?
results want
- this is: internal storage, primary storage, root path
/storage/emulated/0/
- this is: usb stick, secondary storage, root path
/storage/usbdrivea/
- this is: external storage, secondary storage, root path
/sdcard/
i know paths may vary phone phone, how find out path located on storage , permissions have on paths? know can guess names of path, i'm interested in reliable way works on (or @ least on most) phones...
you need check access every primary , secondary storage through environment class. should this:
boolean canwrite = environment.getexternalstoragedirectory().canwrite(); if(canwrite)// externalstorage
and use environment.getrootdirectory() internal root
for usb need check
public static boolean isconnected(context context) { intent = context.registerreceiver(null, new intentfilter("android.hardware.usb.action.usb_state")); return intent.getextras().getboolean("connected"); }
Comments
Post a Comment