Read External Database with SQLiteOpenHelper on Android

Mostasim Billah
1 min readMay 26, 2018

--

To access external SQLite database that store in external storage. In Android SQLiteOpenHelper class by default can access only default data path “data/data/package_name/” this directory.

So, here is a example of how you can access external database from your android application.

Keep in mind that your application has permission to read and write in External SD card in Android manifest.

Step 1:

First, you need to create a contextWrapper that will help you to change the default path in SQLiteOpenHelper class.

Example of contextWrapper:

this wrapper class will take care of all necessary steps to external database path.

Step 2:

Now create a class DataBaseHelper that extend SQLiteOpenHelper class :

Step 3:

Finally create a class that we can instantiate DataBaseHelper class to read and write to our database

Example:

In this way you can read and write to external database.

Thank you for reading. :) :)

--

--