FileProvider 사용

1. FileProvider 설정

2. 다른 앱과 공유 가능 디렉토리 설정

3. 콘텐츠 Uri 획득

  1. 파일 생성
  2. FileProvider,getUriForFile(context, authority, file) 클래스를 사용하여 생성된 파일에 대한 콘텐츠 Uri 획득
// getExternalFilesDir() + "/Pictures" should match the declaration in fileprovider.xml paths
String mPhotoFileName = "IMG"+currentDateFormat()+".jpg";
File mPhotoFile = new File(getExternalFilesDir(Environment.DIRECTORY_PICTURES), mPhotoFileName);

// wrap File object into a content provider. NOTE: authority here should match authority in manifest declaration
Uri imageUri = FileProvider.getUriForFile(this, "com.example.kwanwoo.multimediatest.fileprovider", mPhotoFile);