package com.example.sample;
import android.content.Intent; import android.os.Environment; import android.os.Handler; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import com.truetech.nec.util.NECSharedPref; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.nio.channels.FileChannel; public class SplashScreen extends BaseActivity { // Splash screen timer private static int SPLASH_TIME_OUT = 3000; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.splashscreen_activity);
//fucntion for taking sqlite database backup programmatically
backupDB(); }
//fucntion for taking sqlite database backup programmatically
private void backupDB() { try { File sd = Environment.getExternalStorageDirectory(); File data = Environment.getDataDirectory(); if (sd.canWrite()) { String currentDBPath = "/data/data/" + getPackageName() + "/databases/database.db"; String backupDBPath = "databasename.db"; File currentDB = new File(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, 0, src.size()); src.close(); dst.close(); } } } catch (Exception e) { } }
No comments:
Post a Comment