I am working on Android Application and i am using Suger ORM for my database operation. Now i have scenario where i have to check if "SomeTable" don't exist then create it and Insert the record and if table already exist and having some record i have to update the records. I have write this code to check if table don't exist then create the record and save it.
Total_Budget_List = Total_Budget.listAll(Total_Budget.class);
if (Total_Budget_List.size() == 0)
{
for (int i=0;i<Total_Budget_List.size();i++)
{
totalbudget = new Total_Budget(Select_Members.get(i).getId()+"",CurrentDate,per_person_budget+"");
totalbudget.save();
}
}
But i am getting no such table exist in the database. Now how can i check that if table exist and is there any record in that table.
Surround your code with try / catch block. You can handle SQLiteException if your table not exists.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With