samedi 18 janvier 2020

Android Instrumental Test Database Deleting

this is my Main Database class

public class DatabaseMAIN extends SQLiteOpenHelper {
    public static final String NOME_DB = "DatabaseMAIN.db";
    public static final int VERSION = 4;
    public static final String text =" TEXT NOT NULL ";
    public SQLiteDatabase mDB;

    public enum Tipologia {
        Grids, Structures,Card_representation,Next
    }


    @Override
    public void onCreate(SQLiteDatabase db) {
        //crea il DB la prima volta che l'app viene avviata
        db.execSQL(CategoriesDAO.Categories.creazionec);
        Log.i("Database categories", "creato");
        db.execSQL(CardsDAO.cards.creazionec);
        Log.i("Database Cards", "creato");
        db.execSQL(GridsDAO.Grids.creazionec);
        Log.i("Database grids", "creato");
        db.execSQL(StructuresDAO.Structures.creazionec);
        Log.i("Database Structures", "creato");
        db.execSQL(Cards_RepresentationDAO.Cards_Representation.creazionec);
        Log.i("Database Cards representation", "creato");
        db.execSQL(NextDAO.Next.creazionec);
        Log.i("Database Next", "creato");

    }

I'm performing unit instrumental testing with androidx. I want that at beginning of every test , the database has to be empty, so I need to delete all from it. How can I do? The context is always the same, the context of the app.

Aucun commentaire:

Enregistrer un commentaire