File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Android and the fly likes Android - update SQLite Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "Android - update SQLite" Watch "Android - update SQLite" New topic
Author

Android - update SQLite

Andrzej Sydor
Greenhorn

Joined: Apr 12, 2011
Posts: 8

I have a simple application that supports SQLite.
How to upload new versions of applications that are not deleting, just update the database?
Hauke Ingmar Schmidt
Rancher

Joined: Nov 18, 2008
Posts: 433
    
    2
Have a look at the SQLiteOpenHelper. You can implement methods for upgrading/downgrading, so the thing happens semi-automatic.
Satya Komatineni
author
Ranch Hand

Joined: May 11, 2011
Posts: 38
Hi,
I haven't looked at this aspect in any seriousness. But this is a good question.

The sqlitehelper has the supporting methods but one needs an approach how to use those methods to get what you want.

I will do some research and let you know.

Satya


My Web Site: satyakomatineni.com
Our Book for Tablets/Phones: Pro Android 3
Andrzej Sydor
Greenhorn

Joined: Apr 12, 2011
Posts: 8

Further the question of why examples from the book:
"Professional Android Application Development 2"
do not work.

Downloading code from Chapter 7, which run in the Eclipse and the Android emulator, and I have exceptions.
Why?

Thanks for your interest in the topic!
Hauke Ingmar Schmidt
Rancher

Joined: Nov 18, 2008
Posts: 433
    
    2
Andrzej Sydor wrote:Further the question of why examples from the book:
"Professional Android Application Development 2"
do not work.

Downloading code from Chapter 7, which run in the Eclipse and the Android emulator, and I have exceptions.
Why?

Thanks for your interest in the topic!


You should open an extra thread for this. But please TellTheDetails there; ItDoesntWorkIsUseless, it is not giving enough hints for us to help.
Satya Komatineni
author
Ranch Hand

Joined: May 11, 2011
Posts: 38
Andrzej,

Thank you very much for pointing this out.

I encourage you to contact us for anything like this.

Let me see if I can solve your chapter 7 problem first and then I will address why Pro Android 2 has a problem compiling.

You can access zip files chapter by chapter that you can directly import into eclipse.

Here is the link

Pro Android 2 Downloadable Projects

From this link download the zip file for chapter 7 and you should be able to import into your eclipse ADT. Just to be cautious make sure you are at a higher API level such as 2.3 or so.

if you can't you email me or Dave directly and we will help you out. (Infact I encourage it)

Now coming to why stuff may not compile in ProAndroid2 book:

1. For space saving in many places I haven't included the imports, leaving the eclipse ADT to fill them in. This leaves some discrepancy with package names in the android manifest file that needs to be fixed by hand.

2. With so many chapters and so many examples we have missed to include some XML files. Even with two editors checking things got missed. [Note: It is exteremely hard to present code that can compile right out of the book]. So in book 3 we have provided downloadable zip files so that we may be excused for our follies in the text of the book.

we worked hard to correct this in Pro Android 3

1. We have made a practice to include the list of files where we present examples. This acted as a cross check for us to make sure we dont miss any thing
2. Our technical editor Dylan has put extra emphasis to compile them
3. We have given the zip files on the website for downloads
4. All samples/examples in Pro Android 3 can be found here Pro Android 3 Downloadable Projects

If I can say one final thing, contact us if you can't compile. It is the easiest and the least difficult thing for us to help you on those.

Appreciate again your support

Satya
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

When you write code in your update method for the database, you have to write the alter table scripts, or drop tables, but when you set the version number to a higher number than what was before, the update method will be called. Just remember you have to do all the work yourself writing those ddl statements. Testing it out before putting it out is extremely highly recommended.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Andrzej Sydor
Greenhorn

Joined: Apr 12, 2011
Posts: 8

I have :
Professional-Android-2-Application-Development

Link for the source code:
http://www.wrox.com/WileyCDA/WroxTitle/Professional-Android-2-Application-Development.productCd-0470565527,descCd-DOWNLOAD.html

This Chapter 7 is not correct.

The link:
Pro Android 2 Downloadable Projects
http://www.satyakomatineni.com/akc/display?url=ShowAttachmentsIMPURL&reportId=3468&downerUserId=satya&order_by_format=name

is a book for Professional-Android-2-Application-Development
I have a Android 2.1 (LG GT540)

Evening I will give more information
Dave MacLean
author
Ranch Hand

Joined: May 10, 2011
Posts: 49

Sorry Andrzej, some confusion on our part. Our book is Pro Android 3 and it's being featured this week in this forum. So when Satya saw your post, he thought you were referring to a problem in chapter 7 of our book. But you're talking about Reto Meier's book. You could try reaching him directly through his blog: http://blog.radioactiveyak.com. Hopefully he will help you fix the problems.

- dave

Dave MacLean our book (Pro Android 4)
Andrzej Sydor
Greenhorn

Joined: Apr 12, 2011
Posts: 8

Can we get simple/example application which use SQLite?

I need application where in folder 'assets' a have database SQLite, when i install on Android, then copy/update the database in phone.

And i can run sql statement 'select/update/insert' ?

(Android 2.1) !!!
Dave MacLean
author
Ranch Hand

Joined: May 10, 2011
Posts: 49

In chapter 4 of Pro Android 3, Satya covers how to create a new SQLite DB using DDL within the Android application. The sample code for our chapter 4 can be found from http://www.androidbook.com/projects. But it should be possible to copy files from assets within your APK to the /data/data/<yourpackage>/databases directory to use them from there. Here are a couple of posts on stackoverflow.com that you might find useful:

http://stackoverflow.com/questions/4434367/copy-my-own-sqlite-db-from-asset-folder-to

http://stackoverflow.com/questions/4989300/having-problem-while-copying-sqlite-database-from-assets-to-data-folder

- dave
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Android - update SQLite