Nền tảng Kiến thức - Hành trang tới Tương lai
Card image

Chương 3-Bài 1. Thao tác với bộ nhớ lưu trữ Storage có sẵn bên trong máy (INTERNAL) và thiết bị ngoại vi thẻ nhớ (EXTERNAL)

Tác giả: Dương Nguyễn Phú Cường
Ngày đăng: Hồi xưa đó

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);