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
[email protected]
[email protected]
(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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en