E / SQLiteLog: (10) Failed to read the file, received: 0, amt: 100, last Errno: 2

I use foreign keys in my SQLite DB on Android.

I had a workable database without FK, but now I have several problems.

Firstly, when I try to get a link to db, I have this error.

E/SQLiteLog๏น• (10) Failed to do file read, got: 0, amt: 100, last Errno: 2 

My function:

 public synchronized SQLiteDatabase openDatabase() { if (mOpenCounter.incrementAndGet() == 1) { // Opening new database mDatabase = mDatabaseHelper.getWritableDatabase(); // Get Foreign Key Support mDatabase.execSQL("PRAGMA foreign_keys=ON"); } return mDatabase; } 

Error in line:

 mDatabase = mDatabaseHelper.getWritableDatabase(); 

It seems like the first time this line is called. At other times there is no pb. I'm not sure if this gives me direct errors, but I have a few problems in SQLite, so this can affect bad behavior.

Th

+5
source share
2 answers

Try the following:

 uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" 
+1
source

Not sure if this is your business. I just ran into this now, and what I was trying to do was load sqlite zipped dump from my server and extract it as my SQLite database. I used this post as my guide (still working well in 2016).

I got the same error as you, and when I downloaded the zip file to my laptop and tried to extract it (there were other messages saying that you encountered this error if your new database changes in structure and then you forgot to update the version number of your database), so I can go to the raw sql file, and I got the message "Unable to expand ... Error 2" Error - this means that the zip file is damaged.

I am trying to get an updated version / backup of a zip file to test this theory, but so far all roads have pointed to a damaged zip file. I will keep this up to date.

0
source

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


All Articles