1. Instaling SQLite relies on react-native-SQLite-Storage version 0.60 or above without manual link

    yarn add react-native-sqlite-storage
  2. Add storage read permissions to AndroidManifest.xml

    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
  3. Use the React – Native PermissionAndroid API to request app access to read and write phone storage
  4. Use DB to open the database. If the database is opened successfully, the database operation can be performed

Q&A

1. Error ‘Could not open database’

1. Confirm whether the database storage location is correct.

2. Confirm whether the data read and write permission of the application has been applied.

3. You can use the RNFS.ReadFile API to try to read to verify that the path and permissions are correct.

2. Unable to read and write after applying for read and write permission in Android11. 1. In the AndroidManifest. Add ` XML < USES - permission android: name = "android. Permission. MANAGE_EXTERNAL_STORAGE" / > ` 2. In the AndroidManifest. Add android XML application: requestLegacyExternalStorage = "true" disable partition storage