From Android N, android has changed the way you provide a file URI. Using file:// uri is prohibited and would throw this. Use the FileProvider to overcome this.
Passing file:// URIs outside the package domain may leave the receiver with an unaccessible path. Therefore, attempts to pass a file:// URI trigger a FileUriExposedException. The recommended way to share the content of a private file is using the FileProvider.
More info can be found here