How to correctly access existing files in the app data folder created with an Xamarin.Forms app inside a migrated MAUI app? #21438
Replies: 3 comments 6 replies
-
@ewerspej Thanks for bringing this to light. This is a huge migration issue and I'm surprised (or maybe not at this point) that this topic is not getting any attention. Per the guidelines you posted, LocalApplicationData is the appropriate area for an app database. That pathway should not have changed without some sort of HUGE warning that this was happening. |
Beta Was this translation helpful? Give feedback.
-
@ewerspej thanks for raising this issue, I am also facing the same issue as you have mentioned, however what I am observing is when I upgrade the app on a physical device from Xamarin to MAUI.NET, the path /data/user/0/com.myapp.example/files/.local/share/MySQLite.db3 gets wiped off. It does not exists at all. I have added logging and when app starts up post update, the log says path does not exists. I am trying this from VS IDE in development. Moving across git branches first installing the app and adding some data, post that change branch again deploy it on the physical device and on load it logs "Path does not exists". I am on .net-8 and I am stuck what can be done when the whole folder goes away! Others reading this, please advise do you also face this issue where the entire folder simply vanishes. So far I have tried this in Debug mode, I still have to give Release mode a shot, to see if any difference is shown in the process. |
Beta Was this translation helpful? Give feedback.
-
I've already asked this in a Stack Overflow question, but it seems appropriate to also ask this here:
Is there an official migration path for accessing files in the local application data folder on Android?
Consider the following code in a Xamarin.Forms and a migrated .NET MAUI app:
In Xamarin.Forms, the resulting path on Android is (just like it's documented here):
However, when using the exact same code in MAUI, the resulting path on Android is:
I've resolved this issue by appending ".local/share" to the provided path on Android:
Note: The code above is just exemplary, the actual solution would use preprocessor directives or multi-targeting and constants for the file paths and a const ".local/share" string.
What's the recommended course of action? Is this the way to migrate Xamarin.Forms apps to .NET MAUI when trying to access existing files in an upgraded app?
Beta Was this translation helpful? Give feedback.
All reactions