即使卸载后应用程序中的文件仍然存在 [英] Files within the application remain even after uninstallation

查看:56
本文介绍了即使卸载后应用程序中的文件仍然存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的 Xamarin Forms 应用程序中创建了一些文件.但是,尽管我从手机上卸载了应用程序并使用 VisualStudio 再次调试,但里面的文件仍然存在,以及之前保存的所有内容.怎么解决?

I have created some files within my Xamarin Forms application. but although I uninstall the application from the phone and debug again with VisualStudio, the files inside remain, with everything that was previously saved. How could I solve?

 string DbLocal = Path.Combine(FileSystem.AppDataDirectory, "DbLocal.db3");
 string Emoji = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Emoji.json");

推荐答案

在创建数据库时尝试这样做.

Try doing this while creating your DB.

public readonly SQLiteAsyncConnection dbContext;
private string dbPath;
switch (Device.RuntimePlatform)
{
                case Device.iOS:
                    dbPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "..", "Library", "DbLocal.db");
                    break;
                case Device.Android:
                    dbPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "DbLocal.db");
                    break;
}
dbContext = new SQLiteAsyncConnection(dbPath);

使用此路径进行 DB 将删除卸载应用程序时创建的实际 DB 文件.

Using this path for DB will delete the actual DB file created when you uninstall the application.

---------------------------- 编辑 ---------------------------

---------------------------- EDIT ---------------------------

这里的文件已被删除,因为我用来创建数据库的路径是该应用程序的内部系统缓存路径,当您从设备中删除应用程序时,该路径通常会被清除.路径类似于 InternalStorage->Android/Data/com.packagename.appname/INTERNAL_CACHE_FILES.

The file here was deleted cuz the path I used to create DB was the internal system cache path of that application which usually gets cleaned when you remove the application from device. The path is something like InternalStorage->Android/Data/com.packagename.appname/INTERNAL_CACHE_FILES.

请记住,它是内部存储,而不是外部存储.需要设置root权限来检查文件,也可以通过Android Studio for Emulators

Remember that its the internal storage, not the external storage one. You need to set root permissions to check for files, or you can browse the path through Android Studio for Emulators

永久删除json文件,可以获取json文件的路径&检查天气文件是否存在,如果文件存在,只需将其删除.为此,您可以尝试类似

To delete the json file permanent, you can get the path of the json file & check weather the file is present or not, if the file is present, just delete it. For that you can try something like

if(File.Exists(Emoji))
{
   File.Delete(Emoji); //Emoji is path for your json file
}

这篇关于即使卸载后应用程序中的文件仍然存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆