How to store sqlite database directly on sdcard

i want to create my sqlite database in sdcard instead of default path...i want to access all my data from sdcard also I have Used This Code:

            private static class OpenHelper extends SQLiteOpenHelper {

    OpenHelper(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);


    public void onCreate(SQLiteDatabase db) {
        db.execSQL("CREATE TABLE "
                + TABLE_NAME
                + " (id INTEGER PRIMARY KEY, name TEXT, number TEXT, skypeId TEXT, address TEXT, image BLOB)");

    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {


When i see the database file in default path i can see all the data and table but when i see the database file created in sd card it doesnot shows any data but it only shows the database file

IN constructor it only creates the file in sdcard but in default path it does everything well..... How to store all Sqlitedata on sdcard for further access?

I created my DB with

    public DatabaseHelper(final Context context) {
    super(context, Environment.getExternalStorageDirectory()
            + File.separator + FILE_DIR
            + File.separator + DATABASE_NAME, null, DATABASE_VERSION);

and had no problems further on. I guess your call to super() should reference the sdcard as well.

How to store sqlite database directly on sdcard, i want to create my sqlite database in sdcard instead of default pathi want to access all my data from sdcard alsoI have Used This Code Teams. Q&A for Work. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information.

You are providing an incomplete name in your super() call. Try using:

OpenHelper(Context context) {
    super(context, "/sdcard/"+DATABASE_NAME, null, DATABASE_VERSION);


Other than that, you should always use Environment.getExternalStoreDirectory() to get the path to the external storage, and you should also check the state of the external storage before attempting to use it.

How to create sqlite database in external storage (SDCARD)?, Hi, i wanna know how to create sqlite database in sdcard, could it be done making something like this?: class MyDatabaseOpenHelper(ctx:� SQLite uses a file with .db extension as the database. Where you would like to keep this database file is as per your requirements. On our modules, SD cards are mounted under the /media path. Assuming SD card gets mounted at the path /media/sda1, specifying this path to sqlite3_open will make the database file reside on the SD card.

public DataBaseHelper(final Context context) {

    super(context, Environment.getExternalStorageDirectory()
    + File.separator+ MYDATABASE_NAME, null, MYDATABASE_VERSION);

**Also Add permission in android Manifest
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />**

Using SQLite databases on an SD card in an Android device for , Learn how to use SQLite databases on an SD card in a Android device to the root of the external SD card, for example "/storage/ext_sdcard". I would recommend you NOT to put the database on the SD-card due to partly security issues (everyone who has physical access to the device and the SD-card, including all applications running on the device, will also have more or less full access rights to the database file) but also due to hardware issues (an SD-card has a limited lifespan as of the total number of write operations one can

Just give path in constructor ;

 DatabaseHelper(Context context) {
    super(context, Environment.getExternalStorageDirectory()
            + File.separator + "/DataBase/" + File.separator
            + DB_NAME, null, DB_VERSION);

Android Question, Hi, I wish to use an sqlite db on a tablet's external sd card. allow you to access it directly and the underlying external storage framework is not� Store Data in a Local SQLite.NET Database. 04/01/2019; 10 minutes to read; In this article. Download the sample. In this quickstart, you will learn how to: Use the NuGet Package Manager to add a NuGet package to a project. Store data locally in a SQLite.NET database. The quickstart walks through how to store data in a local SQLite.NET database.

Beginning in Android 6.0 (API level 23), users grant permissions to apps while the app is running, not when they install the app. This approach streamlines the app install process, since the user does not need to grant permissions when they install or update the app.

For getting permissions at runtime, you will have to request the user. You can do that in following way.

First request for permissions.

String[] permissions = {Manifest.permission.WRITE_EXTERNAL_STORAGE};
        requestPermissions(permissions, WRITE_REQUEST_CODE);

And then you can check the results in

public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
    switch (requestCode) {
         if(grantResults[0] == PackageManager.PERMISSION_GRANTED){
           //Permission granted.
           //Continue with writing files...
           //Permission denied.

Here is good learning source requesting-runtime-permissions-in-android-marshmallow/

use SQLite database on SD Card (not using internal , /SD CARD//info.db I want to use an external SQlite database file (not use on Android? and Is it possible to copy couchdb directly to sdcard on android devices ? Is there any way to access database file from External Storage(SD card)? Android studio: Use attach SQLite database file in assets folder with customize adapter - Duration: HOW TO USE A MICRO SD CARD AS INTERNAL STORAGE ON ANY ANDROID DEVICE

How to store sqlite database directly on sdcard, i want to create my sqlite database in sdcard instead of default pathi want to access all my data from sdcard also I have Used This Code: private static class� // Directories on the SD Card for accessing the SQLite database sDataDirectory is string sDataDirectory = "data_wm_androidsqlitedatabasesharepc" // Name of the SQLite database sNameSQLiteDatabase is string = "wm_sqlitedatabase.db" // Unit corresponding to the SD Card of the Android device // (from a Windows application) // To be asked to the user

Insecure Local Storage, Android provides full support for SQLite databases. Databases we Whatsapp is a classic example of SDCARD storage as it stores all its data on SDCARD. Create a database quotes.db using your favorite SQLite database application (DB Browser for SQLite is a portable cross platform freeware, which can be used to create and edit SQLite databases). Create a table ' quotes ' with a single column ' quote '.

android backup sqlite database sd card, Android backup sqlite to sd card. Developers are lazy. What's the Where is the SQLite database stored on an Android device? How to create SQLite database� Copy android app database to sdcard. GitHub Gist: instantly share code, notes, and snippets.

  • Great @koljaTM :) it worked i was missing Environment.getExternalStorageDirectory() Thanx a lot :)
  • @Shiv i had used this method for store db on sdcard now i want to restore one database to this location. can you have try this?
  • and second thing that every device has Environment.getExternalStorageDirectory()? this becuse i had create emulator with no sdcard not this will not work
  • Nice answer @koljaTM. But i have doubt FILE_DIR means what we need to give its a package name?