Good practices with bd Android contract [closed]

2

What would be the good practices regarding sqlite on Android? I use a single db contract for all tables (each table a class inside the main contract class)?

public final class FeedReaderContract {
    // To prevent someone from accidentally instantiating the contract class,
    // make the constructor private.
    private FeedReaderContract() {}

    /* Inner class that defines the table contents */
    public static class FeedEntry implements BaseColumns {
        public static final String TABLE_NAME = "entry";
        public static final String COLUMN_NAME_TITLE = "title";
        public static final String COLUMN_NAME_SUBTITLE = "subtitle";
    }

    public static class OutraTabela implements BaseColumns {
     ....
    }
}

Or do I create a contract class for each table?

    
asked by anonymous 20.08.2017 / 21:50

1 answer

1

The way you're doing is fine. I believe you should also implement a ContentProvider, so specifying the access URIs for each table in Contract is a good one.

In fact, you only need one Contract file. If you have too many tables, maybe you can separate them into multiple files by grouping the tables by subject.

This Google training gives you great directions on the subject:

link

    
20.08.2017 / 23:42