6
SQLiteDatabase BancoDados = null;
String NomeBanco = "Cadastro";
CriaBanco();
public void CriaBanco(){
try{
BancoDados = openOrCreateDatabase(NomeBanco, MODE_WORLD_READABLE, null);
String SQL = "CREATE TABLE IF NOT EXISTS tabCadastro11 ( _id INTEGER PRIMARY KEY, nome TEXT, imagePath TEXT ) ";
BancoDados.execSQL(SQL);
Criapasta();
MensagemAlerta("Banco de Dados", "Banco Criado com Sucesso");
}catch(Exception erro){
MensagemAlerta("Erro Banco de Dados", "Não foi possivel criar o Banco" + erro);
}
finally {
BancoDados.close();
}
}
public void Criapasta() {
File f = new File("/data/data/com.example.gabrielbonatto.oficial/databases/Cadastro"); //Já tentei o NomeBanco e o BancoDados
FileInputStream fis = null;
FileOutputStream fos = null;
try {
fis = new FileInputStream(f);
fos = new FileOutputStream("/mnt/sdcard/meu_banco_dump.db");
while (true) {
int i = fis.read();
if (i != -1) {
fos.write(i);
} else {
break;
}
}
fos.flush();
Toast.makeText(this, "DB dump OK", Toast.LENGTH_LONG).show();
} catch (Exception e) {
e.printStackTrace();
Toast.makeText(this, "DB dump ERROR", Toast.LENGTH_LONG).show();
} finally {
try {
fos.close();
fis.close();
} catch (IOException ioe) {
}
}
}
I read several tutorials for where the db file created in an Android application goes, however I only think using in Eclipse IDE and not in Android Studio.
Does anyone know where this database file created in the application goes ? I wondered why I wanted to use Sqlite Browser to view my database
the path of DDMS only has the folder date and nothing else, I did not find the name of my bank there being q it is already created
– Gabriel Santana Bonatto
Are you using a physical device for this? if you have you need to free access to the bank, Dac way I explained
– Wellington Avelino
I am using Bluestack emulator
– Gabriel Santana Bonatto
I will edit my reply by placing a print
– Gabriel Santana Bonatto
The answer from @Felipedouradinho, fits perfectly for you so, make a dump to export to SD your BD.
– Wellington Avelino
just play the code and it’s over ?
– Gabriel Santana Bonatto