Upgrading free to paid app

Problems with WiFi, SQLite ,Bluetooth, WiMax, Proxies, etc...

Upgrading free to paid app

Postby Skeniver » Mon Oct 12, 2009 3:35 pm

Hi there

I have just realised a dilemma... I plan on having a free limited-time version of an app and a full-function paid version. They will obviously have different packages names, but when a free user buys the full version, how do I get the data out of the free database, and into the paid database?

Is there some way to 'take ownership' of it? Can I access the database and save the data anew? What is the best method?

Thanks in advance,
Neil
User avatar
Skeniver
Senior Developer
Senior Developer
 
Posts: 106
Joined: Tue Feb 03, 2009 3:51 pm
Location: Canterbury, UK

Top

Postby nmc » Mon Oct 12, 2009 9:42 pm

Using the database on sd-card isnt an option for you?

In this case the only thing that comes to my mind is implementing a data-provider in your demo, so the full version can query the db and copy the records to its own database.
nmc
Senior Developer
Senior Developer
 
Posts: 154
Joined: Thu Nov 27, 2008 8:30 pm
Location: Germany

Postby Skeniver » Tue Oct 13, 2009 9:37 am

Hey mmc

I want to avoid using the SD card if possible. Would prefer to get it straight from the app.

I have implemented this to try read from the database (I did create a DBAdapter but that wasn't working so I thought I would just try read a list of databases), but it doesn't return any results...

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. try {
  3.  
  4.         Context other = cont.createPackageContext("com.skeniver.liteapp", Context.CONTEXT_IGNORE_SECURITY);
  5.  
  6.         String[] dbs = cont.databaseList();
  7.  
  8. } catch (NameNotFoundException e) { }
  9.  
  10.  
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


Am I on the right tracks? Do I need to implement anything in the lite version?

Thanks again!
User avatar
Skeniver
Senior Developer
Senior Developer
 
Posts: 106
Joined: Tue Feb 03, 2009 3:51 pm
Location: Canterbury, UK

Postby nmc » Tue Oct 13, 2009 10:59 am

Am I on the right tracks? Do I need to implement anything in the lite version?

Well, I didnt implement something like this so far, but i think your lite version has to expose the database;
the whole private-data security mechanism would be a joke if every app could just use the snipped you provided to access any packages data :wink:

But see padde's comment about "sharedUserId", looks like a more efficient way to achieve your goal :)
nmc
Senior Developer
Senior Developer
 
Posts: 154
Joined: Thu Nov 27, 2008 8:30 pm
Location: Germany

Postby Skeniver » Tue Oct 13, 2009 11:46 am

I have managed to connect to the 'lite' database with the following code:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. Context other = cont.createPackageContext("com.skeniver.applite", Context.CONTEXT_IGNORE_SECURITY);
  3.  
  4. DBAdapter odb = new DBAdapter(other);
  5.  
  6. String[] dbs = cont.databaseList();
  7.  
  8.  
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


and by adding the SharedUserID in the manifest (under the Manifest tag):

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. android:sharedUserId="com.skeniver.app.share"
  3.  
  4.  
Parsed in 0.000 seconds, using GeSHi 1.0.8.4


From there, you can access the database using normal query methods...

I was wondering though, does anyone know now how to best get all the data? Is it possible to make a straight copy of the database? Which would be the easiest and most sensical way...

Thanks,
Neil
User avatar
Skeniver
Senior Developer
Senior Developer
 
Posts: 106
Joined: Tue Feb 03, 2009 3:51 pm
Location: Canterbury, UK

Postby padde » Tue Oct 13, 2009 2:44 pm

If you can access the DB you have the owner rights on it.. so i guess a simple file move should work.
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. File src = new File("/data/data/com.package.nonpaid/databases/mydb.db");
  3.  
  4. File dest = new File("/data/data/com.package.paid/databases/mydb.db");
  5.  
  6. //Maybe you need this line in case there isnt a databases subdir in the target path
  7.  
  8. //dest.mkdirs();
  9.  
  10. src.renameTo(new File(dest, src.getName()));
  11.  
  12.  
Parsed in 0.035 seconds, using GeSHi 1.0.8.4
padde
Master Developer
Master Developer
 
Posts: 443
Joined: Wed Apr 08, 2009 4:52 pm

Top

Postby Skeniver » Tue Oct 13, 2009 3:51 pm

This is the code I have:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. File liteDB = new File("/data/data/com.skeniver.applite/databases/MyDB.db");
  3.  
  4. File fullDB = new File("/data/data/com.skeniver.app/databases/MyDB.db");
  5.  
  6. fullDB.mkdirs();
  7.  
  8. liteDB.renameTo(fullDB);
  9.  
  10.  
Parsed in 0.036 seconds, using GeSHi 1.0.8.4


but when I try to read from the DB, I get a NullPointerException. I have confirmed that both files exist (lite before and full after copying)... any ideas?
User avatar
Skeniver
Senior Developer
Senior Developer
 
Posts: 106
Joined: Tue Feb 03, 2009 3:51 pm
Location: Canterbury, UK

Postby Skeniver » Tue Oct 13, 2009 3:57 pm

In the applications menu, it says that the data is 0kb. So it seems to have copied the DB, but not 'linked' it (read: owned it, attached it, etc)...
User avatar
Skeniver
Senior Developer
Senior Developer
 
Posts: 106
Joined: Tue Feb 03, 2009 3:51 pm
Location: Canterbury, UK

Postby zehunter » Mon Feb 01, 2010 8:08 am

Skeniver wrote:I have managed to connect to the 'lite' database with the following code:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. Context other = cont.createPackageContext("com.skeniver.applite", Context.CONTEXT_IGNORE_SECURITY);
  2. DBAdapter odb = new DBAdapter(other);
  3. String[] dbs = cont.databaseList();
  4.  
Parsed in 0.036 seconds, using GeSHi 1.0.8.4


and by adding the SharedUserID in the manifest (under the Manifest tag):

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. android:sharedUserId="com.skeniver.app.share"
  2.  
Parsed in 0.000 seconds, using GeSHi 1.0.8.4


From there, you can access the database using normal query methods...

I was wondering though, does anyone know now how to best get all the data? Is it possible to make a straight copy of the database? Which would be the easiest and most sensical way...

Thanks,
Neil


hi,

i'm quite interesting by what you write, and this Context.CONTEXT_IGNORE_SECURITY parameter.
can you explain how it work? :)
zehunter
Developer
Developer
 
Posts: 27
Joined: Sun Jan 10, 2010 10:45 am

Postby Skeniver » Mon Feb 01, 2010 11:50 am

To be honest, I am not sure on the implications of changing this parameter. Using IGNORE_SECURITY worked for my purposes, so I haven't ever explored further.

http://bit.ly/bYzare

Here is a link to the developers reference article

sorry I can't help more...
Follow me on twitter -> http://twitter.com/Skeniver
Apps & blog -> http://www.formidableapps.co.uk
User avatar
Skeniver
Senior Developer
Senior Developer
 
Posts: 106
Joined: Tue Feb 03, 2009 3:51 pm
Location: Canterbury, UK

Top

Return to Networking & Database Problems

Who is online

Users browsing this forum: No registered users and 7 guests