dimanche 28 juin 2015

android database overwrite data on exist data

i have a database which have insert,delete,update function database work fine now i add some value to database . i add value in my splash activity like this

    foodDbHelper = new FoodDbHelper(context);
        sqLiteDatabase = foodDbHelper.getWritableDatabase();

        foodDbHelper.addInformations
                ("Paratha", "1 piece", 260, "8.99 g", "5.16 g", "2.18 g", "38.94 g");
        foodDbHelper.addInformations
                ("Chapatti", "1 Piece", 68, "0.62 g", "2.34 g", "0.26 g", "13 g");
        foodDbHelper.addInformations
                ("Alu Paratha", "1 Piece", 329, "6.16 g", "9.08 g", "3.9 g", "38.1 g");
        foodDbHelper.addInformations
                ("Vegetable Biryani", "1 Cup", 170, "0 g", "4 g", "8 g", "36 g");
        foodDbHelper.addInformations
                ("Chicken Biryani", "1 Tray", 480, "15 g", "34 g", "0 g", "51 g");

 foodDbHelper.close();

it store data in database when app run.but problem is that when every time i run app the data store every time and overwrite the exxisting data . when i update are delete value from database and again run the app value again store in database i want when i delete or update any value .and start again app it does not store the deleted value to database.

Aucun commentaire:

Enregistrer un commentaire