Android Question Best Way to move data from one app to another

MrKim

Well-Known Member
Licensed User
Longtime User
I have a free app. If the user buys the paid version I would like them to be able to move their data to the new version.

What is the simplest way to do that?

If I have to add a button in one app for export and another in the other app for import that is fine but I would only like to show those buttons if the other app is installed.

Thanks for your help.
 

Computersmith64

Well-Known Member
Licensed User
Longtime User
Do you already have both the free & paid versions? If not, in my experience it's much easier to put an in-app purchase in the free app than to have a separate paid app.

If you've already gone down that path then you can give the user an option to back the data up to File.DirRootExternal in the free app & then restore it in the paid one - that's what I do in Five Dice.

I think you can find out if a package is installed using PackageManager.

- Colin.
 
Upvote 0

wes58

Active Member
Licensed User
Longtime User
I think that you should have in both application an option to backup/restore data/settings to a file. Since your paid and free application have the same package name this wouldn't be a problem. I don't see a reason for going to in-app-purchasing. Those options are (or should be) in most applications, to ensure that the data is not lost when the user re-installs an application, or moves application to another device.
 
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime User
I think that you should have in both application an option to backup/restore data/settings to a file. Since your paid and free application have the same package name this wouldn't be a problem. I don't see a reason for going to in-app-purchasing. Those options are (or should be) in most applications, to ensure that the data is not lost when the user re-installs an application, or moves application to another device.
The package names won't be the same because you can't publish 2 apps with the same package name.

https://developer.android.com/guide/topics/manifest/manifest-element#package

This name also represents the application ID, which must be universally unique in order to publish your app in Google Play.

The only way the free & paid versions could have the same package name would be if the free version had an IAP to upgrade it to paid.

- Colin.
 
Upvote 0

wes58

Active Member
Licensed User
Longtime User
The only way the free & paid versions could have the same package name would be if the free version had an IAP to upgrade it to paid.

- Colin.
And that's what many application do. Through in-app-purchasing you can remove adds or unlock other features.
 
Upvote 0

wes58

Active Member
Licensed User
Longtime User
Isn't that what I said in my original reply?

- Colin.
Yes you did. But the question was how to move user data from free app to "full" app? And that's what I suggested in reply #3. And whether it is a same or different package names for the apps, it doesn't matter, as long as a backup file has the same format for both. And the file is accessible by both - which is not a problem.
 
Upvote 0

wes58

Active Member
Licensed User
Longtime User
Note that at least one of the apps will need to request the "read external storage" permission as RuntimePermissions.GetSafeDirDefaultExternal is based on the package name.
The user data is stored there. But if you want to make a backup of this data (for whatever reason), you don't need to store it there. You can store it in DirRootExternal or on SD, if the device have it, or better still, you let the user select where to store the backup data. It all depends how you design the application. And the backup data can be encrypted as well if you are concerned about the security.
 
Upvote 0

MrKim

Well-Known Member
Licensed User
Longtime User
Note that at least one of the apps will need to request the "read external storage" permission as RuntimePermissions.GetSafeDirDefaultExternal is based on the package name.
This is where it got confusing for me. RuntimePermissions.GetSafeDirDefaultExternal doesn't seem to return the same dir for each app. I had to use File.DirRootExternal in order to access the backup file from both apps.

I requested runtime permisions

PERMISSION_WRITE_EXTERNAL_STORAGE
PERMISSION_READ_EXTERNAL_STORAGE

and it seemed to work.
 
Upvote 0

MrKim

Well-Known Member
Licensed User
Longtime User
Do you already have both the free & paid versions? If not, in my experience it's much easier to put an in-app purchase in the free app than to have a separate paid app.

If you've already gone down that path then you can give the user an option to back the data up to File.DirRootExternal in the free app & then restore it in the paid one - that's what I do in Five Dice.

I think you can find out if a package is installed using PackageManager.

- Colin.
Yes, package manager gave me what I needed to know. In app purchases seems like the cleanest way for the user but is its own can of snakes as far as implementation and I think I want to provide backup/restore anyway....
 
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime User
This is where it got confusing for me. RuntimePermissions.GetSafeDirDefaultExternal doesn't seem to return the same dir for each app. I had to use File.DirRootExternal in order to access the backup file from both apps.

I requested runtime permisions

PERMISSION_WRITE_EXTERNAL_STORAGE
PERMISSION_READ_EXTERNAL_STORAGE

and it seemed to work.
If you get PERMISSION_WRITE_EXTERNAL_STORAGE, then PERMISSION_READ_EXTERNAL_STORAGE is also granted - so you don't have to request both if you get write permission first.

- Colin.
 
Upvote 0

MrKim

Well-Known Member
Licensed User
Longtime User
If you get PERMISSION_WRITE_EXTERNAL_STORAGE, then PERMISSION_READ_EXTERNAL_STORAGE is also granted - so you don't have to request both if you get write permission first.

- Colin.
Yes, I understand that but it doesn't solve the problem. Each app seems to return a different directory for RuntimePermissions.GetSafeDirDefaultExternal.
 
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime User
Yes, I understand that but it doesn't solve the problem. Each app seems to return a different directory for RuntimePermissions.GetSafeDirDefaultExternal.
I always use File.DirRootExternal for my app backups.

- Colin.
 
Upvote 0
Top