How do I verify that the table exists in SQLite?

Asked 2 years ago, Updated 2 years ago, 37 views

I'm using SQLite on Android, but how do I check if there's a specific table?

android sql

2022-09-22 22:07

1 Answers

 Curser cursor = db.rawQuery ("SELECT name FROM sqlite_master WHERE type='table' AND name = 'table name'", null);
        cursor.moveToFirst();

        if(cursor.getCount()>0){
            return true;
        }else{
            return false;
        }

Do it like this.


2022-09-22 22:07

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.