i am new to android.
In my application i used four classes. loading page,menu class,alarm set class,and database class.When i click on a button in loading page it goes to menu class and in menu class i click on alarm set option ,it goes to alarm set class.After set the alarm, it save the data in database.And i want to show that data in menu class as list view,so i again open data base in menu class and get the data using cursor ,and displayed in list view,
But my problem is when the user start the application very first time ,he is click on a button in loading page ,he have to go to menu class,but error will occur in that time.Because in menu class i open the database but table is not there.i creating the table in alarm set class.So without having table it can’t handle the cursor.
so i want to know is table is exit or not after creating the database.
my code is for creating the database is
alarmDB = this.openOrCreateDatabase(CRAZY_ALARM_DB_NAME, MODE_PRIVATE, null);
An alternative would be to use try/catch. This will stop from error/crashing and you can set options when an exception occurs.
And for tables it would be the same. Like:
If you want a list of all tables then you can check a similar question here: Retrieve a list of all tables in the database