Pergunta

I'd like to make a copy of the database of my application on the sdcard.

The database is located in /data/data/PACKAGE_NAME/databases/ and I'd like to find this path programmatically (so I can use it in my backup activity).

How to retrieve that information?

Foi útil?

Solução

Use getDatabasePath(DATABASE_NAME).getAbsolutePath() in your Activity

Outras dicas

To my knowledge there is no method that will return the folder path of your DB app, as the method for obtaining the data folder. From your Activity uses this method to find the name of your package: getPackageName()

and then you can create a method that returns the path of the folder DB.

public String getPathDB() {
    return "/data/data/" + getPackageName() + "/databases/";
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top