Re: [android-developers] Re: Database updates
OK so here's what I gathered,
after doing some investigation in the adb (AWESOME by the way) I noticed that there was nothing wrong with my inserts. But for some reason the second insert that is attached to INITIAL_SETUP is not run. wierd I know. but that clears up my confusion a bit. I am thinking that each db.execSQL can only use one statement at a time. I may be wrong but for now I think that's how it is.
Luckily I found an article on copying db's over so I can pre-populate the db and then copy it over.
Thanks everyone for the advice and If i'm wrong in my assumptions please feel free to let me know.
Albert Rosa
rosalbert@gmail.com
albert@albert-rosa.com
(m) 718-825-7838
(aim) albertrosa2000
(gchat) rosalbert
(gvoice) (646) 389-7672
On May 3, 2011, at 11:55 AM, Kostya Vasilyev wrote:
> No idea what clearReset is, but....
>
> Call SQLiteDatabase.getVersion() somewhere, just to make sure your db's version is not already 10 (which would mean that there is nothing to upgrade).
>
> -- Kostya
>
> PS - Can I use butter instead of cooking spray? :)
>
> 03.05.2011 18:09, Albert Rosa пишет:
>> Yes I changed the VERSION number on both the dbHelper file as well as the manifest
>>
>> below is the code for the db helper:
>>
>> public class RecipeDbHelper extends SQLiteOpenHelper {
>>
>>
>> private static final String DATABASE_NAME = "test";
>> private static final String DATABASE_TABLE = "recipe";
>> private static final int DATABASE_VERSION = 10;
>>
>> private static final String DATABASE_CREATE = "CREATE TABLE recipe ( _id INTEGER PRIMARY KEY, title text not null, ingredients text not null, instructions text not null, mealtime INTEGER not null, calories INTEGER not null);";
>>
>> private static final String INITIAL_SETUP =
>> "INSERT INTO recipe (_id, title, instructions,ingredients, mealtime, calories) "
>> + "VALUES (1, 'Triple Veggie Scramble','1. Chop all veggies and set aside. Whisk eggs in bowl.\n2. Spray nonstick skillet with cooking spray and saute veggies until soft.\n3. Add whisked eggs, cheese and dash salt and pepper and cook until eggs are firm. \n4. Serve on toasted english muffin with sliced pear on the side.',"
>> +"'3 eggs (1 whole + 2 whites) \n1\\2 cup each chopped tomatoes, spinach and mushrooms\n1 oz reduced fat shredded cheddar cheese\n1 Thomas Light Multigrain english muffin\nSmall pear, sliced.\nsalt/pepper to taste', 1, 124);"
>> ;
>>
>> public RecipeDbHelper(Context context){
>> super(context, DATABASE_NAME, null, DATABASE_VERSION);
>> }
>>
>> public void clearReset(SQLiteDatabase db) {
>> Log.w("Upgrading", "Upgrading database from version");
>> db.execSQL("DROP TABLE IF EXISTS "+ DATABASE_TABLE);
>> onCreate(db);
>> }
>>
>> @Override
>> public void onCreate(SQLiteDatabase db){
>> db.execSQL(DATABASE_CREATE);
>> db.execSQL(INITIAL_SETUP);
>> }
>>
>> @Override
>> public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion){
>> Log.w("Upgrading", "Upgrading database from version " + oldVersion + " to "
>> + newVersion + ", which will destroy all old data");
>> db.execSQL("DROP TABLE IF EXISTS "+ DATABASE_TABLE);
>> onCreate(db);
>> }
>>
>> thanks again I truly appreciate it.
>>
>> Albert Rosa
>> rosalbert@gmail.com
>> albert@albert-rosa.com
>> (m) 718-825-7838
>> (aim) albertrosa2000
>> (gchat) rosalbert
>> (gvoice) (646) 389-7672
>
>
> --
> Kostya Vasilyev -- http://kmansoft.wordpress.com
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscribe@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home