We have a Xamarin Forms App in production that is losing files on some devices. The trigger appears to be an auto-delete feature on Android that happens when devices are bordering full capacity.
We are able to replicate the issue on multiple devices but have not found a variable or storage location that will prevent our app data from being deleted.
We have tried the below Android application variables:
android:allowBackup="false"
android:fullBackupOnly="false"
android:hasFragileUserData="true"
android:manageSpaceActivity=".ActivityOfMyChoice"
We have also tried using 3 different file locations:
public string GetPersonalFilePath(string filename)
{
var path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
return Path.Combine(path, filename);
}
public string GetLocalApplicationDataFilePath(string filename)
{
var path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData);
return Path.Combine(path, filename);
}
public string GetExternalFilePath(string filename)
{
Context context = Android.App.Application.Context;
var filePath = context.GetExternalFilesDir("");
if (filePath != null)
return Path.Combine(filePath.AbsolutePath, filename);
return null;
}
We have spent a few days searching the web for ideas to try but have had no success thus far.
Any potential solution or ideas would be appreciated.