Xamarin forms Application retains SQLite Database even after App is Uninstall and Installed even after manifest is configures to AllowbackUp to false

Viewed 680

I have a offline Xamarin form Application where I save all the data in SQLite for which I am using [praeclarum/ sqlite-net]

and here is how I create My Database

        SqlDataStore.CreateSharedDataStore(
            Path.Combine(
                Environment.GetFolderPath(
                    Environment.SpecialFolder.LocalApplicationData
                    ),
                DataStoreConstants.DatabaseName
                )
            );

This is how I have configured my Manifest

 xmlns:tools="http://schemas.android.com/tools"
        tools:replace="allowBackup" android:allowBackup="false"

I am trying to implement a functionality where SQLite Database should get deleted on Application Uninstalling for which I added android:allowBackup="false" still the database and data inside it retrieves after the Application is Uninstalled and installed back

Also I would Appreciate if someone can help me with what would be good approach to keep my database path right now I am using Environment.SpecialFolder.LocalApplicationData
other Options which I can see for path are

        // Summary:
        //     The directory that serves as a common repository for application-specific data
        //     for the current roaming user.
        ApplicationData = 26,

        // Summary:
        //     The directory that serves as a common repository for application-specific data
        //     that is used by the current, non-roaming user.
        LocalApplicationData = 28,

        // Summary:
        //     The directory that serves as a common repository for application-specific data
        //     that is used by all users.
        CommonApplicationData = 35,
1 Answers

Environment.LocalApplicationData maps to INTERNAL_STORAGE/.local/share . allowBackup works only for application specific data. Xamarin.Essentials has specific APIs to use App specific directory.

Use FileSystem.AppDataDirectory+ "sqlite" to store your SQLite Xamrin.Essentials.FileSystemHelpers

Related