Fixing android.database.sqlite.SQLiteException: no such table: users

intermediate📱 Android2026-07-16| Android SDK, SQLite, Room Persistence Library, Android Studio

Error Message

android.database.sqlite.SQLiteException: no such table: users (code 1 SQLITE_ERROR)
#android#sqlite#room#mobile-dev

The Error ScenarioYou’ve written the code, defined the table, and hit 'Run'—only to watch your app crash immediately. It’s a classic Android development headache. You just added a new table or modified your schema, but the logcat throws a frustrating error:

android.database.sqlite.SQLiteException: no such table: users (code 1 SQLITE_ERROR)

The system insists the table doesn't exist, even though you can see the CREATE TABLE statement right there in your Java or Kotlin file. This disconnect happens because the database on your device is out of sync with the code in your IDE.

Why This HappensThe Android OS is efficient, but it can be stubborn. This error usually boils down to how the system manages the database lifecycle. Here are the primary culprits:

  • The onCreate() Trap: The onCreate() method in SQLiteOpenHelper runs exactly once: when the database file is first created. If you add a 'users' table to your code after the app has already been installed, onCreate() will not run again. The old database file remains, missing your new table.- Stale Version Numbers: You modified the schema but kept DATABASE_VERSION = 1. Android won't trigger an update unless that number increases.- Room Migration Safety: Room is protective. If you change your @Entity classes without providing a migration path, Room often defaults to an error state rather than risking data loss.- Case Sensitivity and Typos: While SQL is often case-insensitive, SQLite can be picky about quotes and exact string matches in complex queries.## Step-by-Step Fixes### 1. The "Nuke and Pave" ApproachIf you are in early development and don't have important user data, don't waste time on complex migrations. Just wipe the slate clean.
  • Uninstall the App: Long-press your app icon and select Uninstall. This deletes the .db file located in /data/data/your.package.name/databases/. On the next run, onCreate() executes fresh.- Clear Storage: Open Settings > Apps > [Your App] > Storage > Clear Data. This is faster than a full reinstall and achieves the same result.### 2. Incrementing the Database VersionFor apps using standard SQLiteOpenHelper, you must signal the OS that the schema has changed. Move your version from 1 to 2 (or whatever the next integer is).
public class MyDatabaseHelper extends SQLiteOpenHelper {
    private static final String DATABASE_NAME = "UserStore.db";
    // Increment this to trigger onUpgrade()
    private static final int DATABASE_VERSION = 2;

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL("CREATE TABLE users (id INTEGER PRIMARY KEY, username TEXT)");
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        if (oldVersion < 2) {
            db.execSQL("CREATE TABLE users (id INTEGER PRIMARY KEY, username TEXT)");
        }
    }
}

3. Solving Room Migration IssuesRoom requires explicit instructions when the schema changes. You have two main paths.

Destructive Migrations (Dev Only)Tell Room to simply delete the old database and start over if the version changes. This prevents the 'no such table' crash but wipes all existing data.

database = Room.databaseBuilder(context, MyDatabase.class, "app-db")
        .fallbackToDestructiveMigration()
        .build();

Manual Migrations (Production)If you have users with existing data, use a migration object. This ensures the 'users' table is created during the transition from version 1 to 2.

static final Migration MIGRATION_1_2 = new Migration(1, 2) {
    @Override
    public void migrate(SupportSQLiteDatabase database) {
        database.execSQL("CREATE TABLE IF NOT EXISTS `users` (`id` INTEGER NOT NULL, `name` TEXT, PRIMARY KEY(`id`))");
    }
};

Using the Database InspectorStop guessing. Use Android Studio's Database Inspector to see exactly what is on the device disk.

  • Deploy your app to an emulator or physical device (API 26+).- Open the App Inspection tab at the bottom of Android Studio.- Select the Database Inspector.- Look at the table list. If users isn't there, your onCreate or onUpgrade logic didn't fire. You can even run SELECT * FROM users directly in the inspector to test the table's existence in real-time.## SummaryThe "no such table" error is almost always a versioning issue. Android is simply trying to protect the existing database file. By incrementing your version number or clearing the app data, you force the system to recognize your new schema and create the missing tables.

Related Error Notes