Вопрос

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?

Это было полезно?

Решение

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

Другие советы

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/";
}
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top