database update

by Dan » Fri, 26 Feb 2010 00:40:30 GMT


Sponsored Links
 I've got a question about updating an app after release.  If I have a
database that contains 10 columns and I add a feature that requires an
11th column after the app has been released, where would I put the sql
code to add the new column so that when they install the app it keeps
their current data, but adds that 11th column?  Is that even possible
or would I need to create another table that references the first with
a foreign key?

--



database update

by Mark Murphy » Fri, 26 Feb 2010 00:45:06 GMT


 


In onUpgrade() of your SQLiteOpenHelper subclass.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://twitter.com/commonsguy 

Warescription: Three Android Books, Plus Updates, One Low Price!

--


Sponsored Links


database update

by Kevin Anthony » Fri, 26 Feb 2010 01:53:55 GMT


 Alter
 http://www.techonthenet.com/sql/tables/alter_table.php 

Kevin




I've got a question about updating an app after release.  If I have a
database that contains 10 columns and I add a feature that requires an
11th column after the app has been released, where would I put the sql
code to add the new column so that when they install the app it keeps
their current data, but adds that 11th column?  Is that even possible
or would I need to create another table that references the first with
a foreign key?

--



database update

by Dan » Fri, 26 Feb 2010 04:35:36 GMT


 thanks, so the onCreate gets called when the database has not been
created and the onupgrade gets called when the database has been
created, but the app is being upgraded?  Do these methods get called
due to some global variable that gets reset upon a fresh or upgraded
install of the app?






--



database update

by Mark Murphy » Fri, 26 Feb 2010 05:24:47 GMT


 


Yes on the first. More accurately for the second, onUpgrade() will be
called when the schema revision (parameter in the SQLiteOpenHelper
constructor) changes.


No, they get called when you ask your SQLiteOpenHelper subclass to
getWriteableDatabase(), for example. The determination of whether an
upgrade is needed is based on some metadata tucked away in some corner
of the database.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://twitter.com/commonsguy 

Warescription: Three Android Books, Plus Updates, One Low Price!

--



Other Threads

1. Dialog Survival Over Configuration Change



Why do you say that? Opening or closing the keyboard counts as a
configuration change, so it's something that can happen at any time.


Unless you take measures to avoid it, a configuration change will
cause your activity to be destroyed and recreated with the new
configuration. It goes through the normal activity lifecycle when
doing this, so to the current activity is paused, stopped and
destroyed, and the new activity is created, started and resumed.

--~--~---------~--~----~------------~-------~--~----~

2. What is wrong with this layout

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/bkg"
    >
    <TextView
    android:layout_width="fill_parent"
    android:layout_height="200px"
    android:text="@string/hello" >
    </TextView>
    <LinearLayout
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="55px"
    android:gravity="center">
    <Button android:id="@+id/installRing"
    android:layout_width="wrap_content"
    android:layout_height="52px"
    android:background="@drawable/installBtn">
        </Button>
    </LinearLayout>

</LinearLayout>

I cannot understand what is wrong with this layout. I keep getting
this error in the xml saying Element type "Button" must be either
followed by attributes or > or />
I don't understand why the editor can't recognize android:id as an
attribute! I tried writing the whole XML again but keep getting this
error!

Thanks for any help.

--~--~---------~--~----~------------~-------~--~----~

3. Looking for a way to build resolution independent layout xml?

4. citys in india

5. How to mount the microSD disk programmatically?

6. Error happened when I run make

7. Multi-process applications and Android Market