Like copying a file or database from internal to external storage, sometimes we need to read files inside internal storage ( data/data
), which is only possible if the device has root permissions.
In the case of a device that does not have these permissions, it is impossible to access the information.
How to export and import an Android SQLite database?
I suggest this method
which would be called in this way, knowing the package of your application and the name of the file or database saved, you indicate the source and destination of the file to copy:
Don't forget to add the permission to be able to write to external storage:
With this method you can copy both files and a database to the external storage so that you can easily open the files:
*Important:
to use the WRITE_EXTERNAL_STORAGE permission on devices with an operating system greater than Android 6.0 (which is also implicitly
READ_EXTERNAL_STORAGE
) it must be required manually:Use this method:
Check this question:
Error displaying external file directory in android 6.0 (READ_EXTERNAL_STORAGE / WRITE_EXTERNAL_STORAGE )