android - What is the right way of checking conditions in content providers? -


i have sqlite database , content provider wraps it. there table of dictionaries , table of words. eeach word belongs 1 of dictionaries. each dictionariy has constant capacity. content provider should allow insert limited amount of words in each dictionary.

 "scheme"  dictionaries |-id (read-only) |-capacity  words |-id (read-only) |-dictionaryid (write-once) 

i have few options:

1) each new dictionary can create trigger raise() error if amount of words gather capacity. make query each insertion redurant in situations.

2) can check condition in provider's insert(). (same problem above)

3) can pass check users of provider. example check condition in activity adds new words dictionary. optimized method because don't need make query each time add new word. can query amount of words in dictionary @ start of activity , increment , aware of relevant value without queries. here have problem: if forget check condition or make mistake , condition won't work.

so right way of checking conditions in content providers?

i've decided extract logic of working data database , use db mere container. reason frees me doing tests database not easy see. better think consider database robust , based on create tests application components.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -