Banco de dados - colocando no SDCard

Top  Previous  Next

 

 

String DATABASE_NAME = "banco.db";

File sdcard = Environment.getExternalStorageDirectory();

String dbfile = sdcard.getAbsolutePath() + File.separator + "external_sd" + File.separator + DATABASE_NAME;

 

// exibe o local do banco

Toast.makeText(ctx, dbfile, Toast.LENGTH_SHORT).show();

         

// abre...

dbHelper = new SQLiteHelper(ctx, dbfile, RepositorioCarroScript.VERSAO_BANCO, RepositorioCarroScript.SCRIPT_DATABASE_CREATE, RepositorioCarroScript.SCRIPT_DATABASE_DELETE);

 

-OU-

 

DB = SQLiteDatabase.openDatabase(dbfile, null,SQLiteDatabase.NO_LOCALIZED_COLLATORS);