Is it possible to clear cache data of an app (ex. youtube) using my Flutter app. I'm trying to do something like:
var app = await DeviceApps.getApp('com.google.android.youtube');
var dir=Directory(app?.dataDir);
dir.deleteSync(recursive: true);
But I got: Unhandled Exception: FileSystemException: Deletion failed, path = '/data/user/0/com.google.android.youtube' (OS Error: No such file or directory, errno = 2)
CodePudding user response:
I don't actually think it is possible to clear app data using another app, that is something needs to be handled by the OS in order to avoid data manipulation.
you can use packages like flutter_cache_manager to delete your app cache but not that of other installed apps
CodePudding user response:
Yes it is possible to delete the cache data . You can use this package flutter_cache_manager
. Follow the code:
await DefaultCacheManager().emptyCache();