Search code examples
databaseandroidbackupsd-card

How do I backup a database file to the SD card on Android?


I'd like to add a feature to my Android app that automatically backs up the SQLite database to the SD card.

What's the best way to go about this? Are any examples or tutorials available?


Solution

  • SQLite databases are completely self-contained files and are portable — you can just copy the entire file straight to the SD card.

    Though first I'd check whether an SD card is installed in the device, and what its path is (using Environment.getExternalStorageDirectory()).