File saved by previous installation not recognized

I have faced this in the past and again with my new app - a text or Json file created by an old APK version can’t be found by a new version after re-installation.

I use the File component to save the file in the app assets.
Then make a copy of it in the Downloads folder with TaifulFile extension.

In APK test on device, if I uninstall the old version and install a new version, the old file saved in Downloads folder is not found. The file is however found if I merely update the old version with the new.

Attaching the blocks I am using.

The file basically exports the tinyDB data to the device, so that it can be imported by a new installation.

blocks 3

blocks 1

Yes, this is correct
Therefore do not uninstall the old version, just make an update of your app


Okay, thanks. I was wondering why should this happen? And is there any way the old file could be used?

Due to Scoped Storage, introduced in Android 10.

You can access a non-media file created by your app as long as app is installed. Once you uninstall the app, you lose its owner permission and thus you can’t read or write to it.
However, you can still access it with SAF.

1 Like

Thanks, this is good.