How to get the path to my SQLite database?

2

I need my app to back up and restore the data that is written to SQLite. I followed some internet tutorials but I am not able to copy the data!

String packageName = contexto.getPackageName();
String NOME_BD = "estudos_sql.bd";
String BD_FILEPATH = "/data/data/" + packageName + "/databases/" + NOME_BD;

My problem is that I can not find the database file ( BD_FILEPATH ) even though it is working normally !!! ??? Is it a permissions issue?

    
asked by anonymous 05.06.2015 / 12:17

1 answer

4

If your database was created in the traditional way using the SQLiteOpenHelper class, you can get its path through:

String dbPath = context.getDatabasePath("nome da db").toString();
    
05.06.2015 / 13:55