I want to make a crime list which contains at least one crime when I install and initiate application without touching add button.
I mean I want to insert rows in database without touching add button and executing the code in onOption ItemSelected() method.
I tried making crime instances using “new Crime(…)” in the CrimeLab.java’s constructor. But this method create duplicated crime list when I restart application.
I also tried make ‘insert query’ inside ‘db.execSQL’ in CrimeBaseHelper class’s onCreate method cuz I know that onCreate() will be executed only once when there is no db table. Inserting rows only once is what I want.
In this approach, I create new Crime instance then I used insert query in order to save field’s value into the table. But I my app crashed.
My question is that is this right approach? Using insert query in onCreate()?
I’m looking forward to your answer!! Thanks in advnace.