How to check Exist table or not in Suger ORM Android

I am working on an Android application and I am using Suger ORM for my work with the database. Now I have a script where I have to check if "SomeTable" exists, then create it and insert a record, and if the table already exists and have some record, I have to update the records. I wrote this code to check if there is a table, then create a 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 do not see such a table in the database. Now, how can I check if a table exists and if there is any record in this table.

+5
source share
1 answer

Surround your code with a try / catch block. You can handle SQLiteException if your table does not exist.

+3
source

Source: https://habr.com/ru/post/1211354/


All Articles