public void createDemoData(SQLiteDatabase db) { db.execSQL(DROP_PCL_SCORE_TABLE); db.execSQL(PCL_SCORE_TABLE_CREATE); int i; float fy = (float) (17 * 4.5); long startingTime = -120L * 24 * 60 * 60 * 1000; Date now = new Date(); for (i = 0; i < 15; i++) { long fx = i * 8; int score = (int) (fy + (14 * Math.random() - 7)); if (score < 17) score = 17; long ts = now.getTime() + startingTime + (fx * 24 * 60 * 60 * 1000); long delta = now.getTime() - ts; long deltaDays = delta / (24 * 60 * 60 * 1000); Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(ts); DateFormat df = new DateFormat(); CharSequence s = df.format("MMMM dd, yyyy h:mmaa", cal); ContentValues values = new ContentValues(2); values.put("score", score); values.put("time", ts); db.insert("pclscore", null, values); fy = (float) (fy * 0.9); } db.execSQL(DROP_EXERCISE_SCORE_TABLE); db.execSQL(EXERCISE_SCORE_TABLE_CREATE); db.execSQL(EXERCISE_SCORE_INDEX1_CREATE); db.execSQL(EXERCISE_SCORE_INDEX2_CREATE); for (String fave : demoFavorites) { Content c = contentDB.getContentForName(fave); ContentValues values = new ContentValues(2); values.put("score", 1); values.put("name", c.getDisplayName()); values.put("exerciseUniqueID", c.uniqueID); db.insert("exercisescore", null, values); } }
public UserDBHelper(Context ctx) { super(ctx, DB_NAME, null, DATABASE_VERSION); context = ctx; contentDB = ContentDBHelper.instance(ctx); }