[android-developers] Re: Database updates

2011-05-03 Thread Chambras
where did you change the version? in the manifest file or in the java class?

-- 
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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: Database updates

2011-05-03 Thread harsh chandel
can you put the code

On May 3, 5:58 am, Albert Rosa rosalb...@gmail.com wrote:
 So this is my first time working with android and the sqlite db. I followed
 the instructions and was able to have a db connection where i was able to
 create and edit records. However i changed the schema of the db just to make
 it easier on me.

 Here is when i get slapped, i updated the version number, and modified the
 create statement to reflect the change. The onUpdate function is not being
 hit when i run the app again.

 Im not sure what I may be doing wrong. Any help suggestions are greatly
 welcomed and appreciated.

 Thanks for the help!

-- 
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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: Database updates

2011-05-03 Thread 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
rosalb...@gmail.com
alb...@albert-rosa.com
(m) 718-825-7838
(aim) albertrosa2000
(gchat) rosalbert
(gvoice) (646) 389-7672

On May 3, 2011, at 4:18 AM, harsh chandel wrote:

 can you put the code
 
 On May 3, 5:58 am, Albert Rosa rosalb...@gmail.com wrote:
 So this is my first time working with android and the sqlite db. I followed
 the instructions and was able to have a db connection where i was able to
 create and edit records. However i changed the schema of the db just to make
 it easier on me.
 
 Here is when i get slapped, i updated the version number, and modified the
 create statement to reflect the change. The onUpdate function is not being
 hit when i run the app again.
 
 Im not sure what I may be doing wrong. Any help suggestions are greatly
 welcomed and appreciated.
 
 Thanks for the help!
 
 -- 
 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+unsubscr...@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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: Database updates

2011-05-03 Thread Kostya Vasilyev

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
rosalb...@gmail.com
alb...@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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: Database updates

2011-05-03 Thread Albert Rosa
Ok so I've been able to place crazy amounts of logs every where and it does see 
to call onUpgrade to the next version and it is able to drop the table. 

I want validate the sql that its generating in order to get all the items. is 
there a way to get the raw sql that it's generating. I feel like i may be doing 
something wrong, rather I know I'm doing something wrong I just don't know... 

clearReset was a function I created in order to drop the table and reset it 
with preset data. it can be ignored.

I will try to find the db in the emulator by adb maybe I might surprise myself.


Albert Rosa
rosalb...@gmail.com
alb...@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
 rosalb...@gmail.com
 alb...@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+unsubscr...@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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: Database updates

2011-05-03 Thread Albert Rosa

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
rosalb...@gmail.com
alb...@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
 rosalb...@gmail.com
 alb...@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+unsubscr...@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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en