简体   繁体   中英

Android studio cannot read my sqlite database

I am doing my university project which requires creating a database. I created a database in DB Browser for SQLite and it looks like this: enter image description here

but when I copied this into Android Studio it looks like this: enter image description here

Android Studio reads my Setting table normally, but when it comes to my WokroutDays table it says that I don't have this table.

This is the print out of an error:

E/AndroidRuntime: FATAL EXCEPTION: main
   Process: com.example.seniorapplication, PID: 24122
    android.database.sqlite.SQLiteException: no such table: WorkoutDays (Sqlite code 1): , while compiling: INSERT INTO WorkoutDays(Day) VALUES('1602576762730');, (OS error - 2:No such file or directory)
        at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)

or maybe it is the problem with my saving method saveDay:

public void saveDay(String value){
     SQLiteDatabase db = getReadableDatabase();
     String query = String.format("INSERT INTO WorkoutDays(Day) VALUES('%s');",value);
     db.execSQL(query);
}

Did you try reinstalling your app and building again? Because sqlite tables modifies in app when it freshly installs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM