android-sdk – SQLite error – Failed to do file read

Question:

I create a local BD on android (SQLite), there are about 15 tables in the database. When creating the first 9, everything goes without errors, but starting from the 10th table, the following lines appear in the logs:

 E/SQLiteLog: (10) Failed to do file read, got: 0, amt: 4096, last Errno: 2

The error crashes more than 10 times on the last 5 tables. The application itself does not crash and installs normally on the device. Further, the database itself in conjunction with the application is working normally – as if there were no errors. The presence of this error worries me, it is not clear when and where it will come around. I myself cannot figure out what kind of error it is and where it comes from.

Answer:

Fixed creation of tables in SQLite database, added "NOT NULL" statements for fields that are specified in the table as "primary key" or "foreign key".

example for clarity:

db.execSQL(
            "create table "+ TBL_myOBJECT +" ("+
                    "_id integer NOT NULL,"+
                    "Name_obj text, "+

                    "primary key (_id) "+
                    ")"
    );

    db.execSQL(
            "create table "+ TBL_TYPE_FILE +" ("+
                    "_id integer NOT NULL,"+
                    "Name_type text, "+

                    "primary key (_id) "+
                    ")"
    );

    db.execSQL(
            "create table "+ TBL_OBJ_FILE +" ("+
                    "_id integer NOT NULL,"+
                    "Size_file integer, "+
                    "Date_create integer, "+
                    "Name_file text, "+
                    "Object_id integer NOT NULL, "+
                    "TypeFile_id integer NOT NULL, "+

                    "primary key (_id), "+
                    "foreign key (Object_id) references "+TBL_myOBJECT+" (_id),"+
                    "foreign key (TypeFile_id) references "+TBL_TYPE_FILE+" (_id)"+
                    ")"
    );
Scroll to Top