Is it possible to read/write to SQLite on a removable USB Flash Drive

  • Replies:2
Mark Anderson
  • Forum posts: 1

Apr 6, 2018, 12:41:34 AM via Website

Is it possible to read/write to SQLite on a removable USB Flash Drive, by this I mean the app is installed on the phone, but the data used by the app would be stored on a removable USB flash drive that plugs into the USB/Charging port.

I have been reading a lot and for the most part references to this suggest the data must be in the same location as the app. I need the data to be external to the app so different databases can be used as required. If it is possible, I would appreciate a reference to some example or explanation.

thanks

Reply
James Watson
  • Forum posts: 1,584

Apr 6, 2018, 4:04:01 AM via Website

We can read/write to SQLite on a SD card. So I think you can do on an USB drive, too.

public static final String DATABASE_FILE_PATH = "/sdcard";
public static final String DATABASE_NAME = "testDatabase";

database = SQLiteDatabase.openOrCreateDatabase(DATABASE_FILE_PATH + File.separator + DATABASE_NAME, null);

Download size < 0.15 MB. But also accurate enough, ad-free & free.
The minimalist app available on Play Store: https://goo.gl/ws42fN
Blog: https://okblackcafe.blogspot.com Your 5-star is appreciated.

Helpful?
Reply
Mark Gonzales
  • Forum posts: 22

Apr 6, 2018, 5:41:36 AM via Website

Hi Mark,
Yes, you can save the app on your SD card which will work same as the app is installed on the phone, however, it is still best for all our apps both internal and external to be installed directly to the phone memory. Hope this helps

Helpful?
Reply