Two last questions before I release my app :)

Hi! So I have two last questions before I release my game to Google Play.

  1. Im going to have two different version, one free with ads and one for 1$. Should I use the same key to sign both since that would make installation easier for the user incase they upgrade? I also just thought of that If they have the Free version first and want to upgrade to the other, they will have to delete their saves and high-scores to install the new one so I guess one key to sign when exporting a apk is right? :slight_smile:

  2. Is it worth getting Google Play Licensing Check for me since I have both a free and paid version?

Thanks for reading :slight_smile:

I use the same key to sign everything. I don’t know of any reason to use multiple keys!?

I guess if you forsee your app becoming reasonably popular, and the losses from piracy being relatively high, then it could be worth a thought. Otherwise I’d avoid it. (I have a hard enough time getting people to purchase my app, let alone pirate it! ;D)

Oh, I thought it was wise to have a different key for everything, but I can see it being better to have one for everything. Also I guess I will avoid the License Check then, since I don’t really see my game being the new Angry Birds. I also have a free version with only simple banner ads so I don’t see the point in them pirating it, though it would be a little fun to watch people going through all that trouble just to play my game without ads :slight_smile: Thanks for the answer!

Okay, another problem I have is that I had to create two different android projects (both linked to the main source of the game) with a “.free” at the free versions packaging name in the AndroidManifest, because you cant have two apps with the same packaging on Google Play. But this makes it so that the user have to restart everything if they upgrade from the free version to paid version.

All I want to is that I could save the preference file to a specific place (so it wont get removed if the free version gets removed) and make the paid version read it. And Im using LibGdx btw :slight_smile:

In my (small) personal experience, save your game data with SharedPreferences. Android will do all the dirty work for you, and it is fast.
Also, I made a quick search, and you can share same app data if your second app is a child.
Example:
free version: com.package.game
paid version: com.package.game.paid

You must use paid as a child of free (not otherwise). Because if you use:
free version: com.package.game.free
paid version: com.package.game

This will not detect your data (at least that is what I think), because your original package don’t have any child.

For more information, read matt5784 answer HERE. (Just the first part, you don’t need to backup nothing, etc):

[quote]it appears to be possible to share preferences between applications if a few requirements are met. First, if you want App B to be able to access App A’s preferences the package name of App B must be a child of App A’s package name (e.g. App A: com.example.pkg App B: com.example.pkg.stuff). Additionally, they can’t be wanting to access the file at the same time
[/quote]

Thanks for the answer, but a lot of people seemed against using that method :frowning: I have tried doing it now with using Context. I’m able to find the preference file, but it’s not able to get the contents from the preference file itself, since it always returns 0 (the default value). Is this because I use LibGdx? I have read that LibGdx saves its own preference files as SharedPreferences on Android so that shouldn’t be the issue.

public void tryLoadPrefs(){
		Context otherAppsContext = null;
		
		try {
			otherAppsContext = createPackageContext("com.mayogames.zombiecubes.free", 0);
		} catch (NameNotFoundException e) {
			System.out.println(e);
		}
		
		System.out.println("Extracting = " + otherAppsContext.getSharedPreferences("Settings", CONTEXT_IGNORE_SECURITY).getInt("seconds", 0));
	}

EDIT: Im loading in the onCreate() method. Is that a problem?

You don’t need to use try, if there is no data value return the default value you put. And, you don’t need to create package. Android will do this for you.

Use something like this to create saved file:

int lvlComplete = 10;
SharedPreferences.Editor saveLevel = getSharedPreferences("game_name", 0).edit();
saveLevel.putInt("levels", lvlComplete);
saveLevel.commit(); // do not forget to commit.

And to load game data:

SharedPreferences getData = getSharedPreferences("game_name", 0);
int lastLevel = getData.getInt("levels",0);   // use getInt, getBoolean, getString, etc.

Using that method I only got the paids version own SharedPreference and not the Free version one :frowning:

SharedPreferences getData = getSharedPreferences("Settings", 0);
		int lastLevel = getData.getInt("seconds", 0);   // use getInt, getBoolean, getString, etc.
		
		System.out.println(lastLevel);

I have absolutely NO IDEA what happend, but when I changed it to this

public void tryLoadPrefs(){
	      Context otherAppsContext = null;
	      SharedPreferences getData = null;
	      
	      try {
	         otherAppsContext = createPackageContext("com.mayogames.zombiecubes.free", 0);
	         getData = otherAppsContext.getSharedPreferences("Settings", 0);
	      } catch (NameNotFoundException e) {
	         System.out.println(e);
	      }
	      
	      System.out.println("Extracting = " + getData.getInt("seconds", 0));
	}

It suddenly imports every single data over to my paid version? o.O Of course Im happy, but Im a little scared this is a stupid way since I dont understand how it did so… Is it maybe because the line “getData = otherAppsContext.getSharedPreferences(“Settings”, 0);” got the Settings file from the Free version AND at the same time made a own in the Settings and set that because of the equal sign? :slight_smile:

“Using that method I only got the paids version own SharedPreference and not the Free version one”

Well, it works now and you don’t need more code, but can you show me full packages name from paid and free version?

I’m able to get the info now, but I’m having trouble saving the info into its own file. It seems like its linked to the Free version one, because instead of creating or saving into it’s own folder, it saves to the Free version one. I think this is because of LibGdx, but I’ll continue to mess around to see if I can get it to work.

The package name is:
com.mayogames.zombiecubes
com.mayogames.zombiecubes.free

Change package names.
Free: com.mayogames.zombiecubes
Paid: com.mayogames.zombiecubes.paid

Read again my second comment. Everything should work now.
Paid version can access Free version data (but free version data cannot access paid version). No problem though users upgrade from free to paid version, not otherwise.

Yeah, I did read that, but as I said, there was a lot of people against it so I wanted to try another method :slight_smile: I did managed to get it to work now, by making the Free version name the settings preference “SettingsFreeVersion” instead and the paid version just “Settings” :slight_smile: