Trong file AndroidManifest.xml, cần thêm trường:
<application
        android:name="com.nentang.doanthanhnien.CustomApplication"
        android:allowBackup="true"
        android:hardwareAccelerated="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:networkSecurityConfig="@xml/network_security_config"
        android:requestLegacyExternalStorage="true"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"
        tools:targetApi="n">
...
</application>
Khi viết code cần khai báo thêm quyền:
// Request permission WRITE EXTERNAL STORAGE
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1);