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

This code works for me! try { File sd = Environment.getExternalStorageDirectory(); File data = Environment.getDataDirectory(); if (sd.canWrite()) { String currentDBPath = “//data//{package name}//databases//{database name}”; String backupDBPath = “{database name}”; File currentDB = new File(data, currentDBPath); File backupDB = new File(sd, backupDBPath); if (currentDB.exists()) { FileChannel src = new FileInputStream(currentDB).getChannel(); FileChannel dst = new FileOutputStream(backupDB).getChannel(); dst.transferFrom(src, … Read more

Find location of a removable SD card

Environment.getExternalStorageState() returns path to internal SD mount point like “/mnt/sdcard” No, Environment.getExternalStorageDirectory() refers to whatever the device manufacturer considered to be “external storage”. On some devices, this is removable media, like an SD card. On some devices, this is a portion of on-device flash. Here, “external storage” means “the stuff accessible via USB Mass Storage … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)