how to check if a Uri user selected from action_open_document tree is got from removable Sd card? i check this but its same for primary sd card and removable sd card! is there any other way?
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
String id=DocumentsContract.getTreeDocumentId(uri);
Uri mainuri=DocumentsContract.buildDocumentUriUsingTree(uri,id);
grantUriPermission(G.context.getPackageName(), uri, Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
if( "com.android.externalstorage.documents".equals(uri.getAuthority())){
// its return true for primary and removable sd card !!
}
No.
There is no requirement that a
Uri
from a storage provider be identifiable in any way. Your assumption (that the authority iscom.android.externalstorage.documents
for a certain storage provider) does not have to be correct on any Android device. Device manufacturers can supply their own storage providers, with their ownUri
structures.