malformed database

Smee

Well-Known Member
Licensed User
Longtime User
I am getting the following error when trying to initialise a database

android.database.sqlite.SQLiteDatabaseCorruptException: database disk image is malformed: , while compiling: PRAGMA journal_mode=TRUNCATE

The file opens ok with sqllite administrator on windows. i have done a database clean and it shows everything is ok. I ftp upload the database (binary) and then ftp download to a tablet.

if i try a different database same name etc(old back up) it downloads and initialises properly.

Can anyone advise any ideas on how to repair or fix this problem?

Thanks
 

Mahares

Expert
Licensed User
Longtime User
Assuming you have one table. An option:
1. Make a copy of the old back up database and delete its records.
2. Since you can open the CORRUPTED one via Windows administrator, import its records into the blank table via Windows administrator.
3. Test it. If it works, then delete the corrupted one and rename the new one to the original name of the corrupted one.
 
Upvote 0

Smee

Well-Known Member
Licensed User
Longtime User
@ Mahares. Sorry it is not that simple. The corrupt database would be on a users tablet so it needs to be fixed in code on the tablet.

Erel,

The deviced is a xoom. The problem happens when the SQL.Initialize statement is issued. Therfore the database is not opening.

Any ideas?

Thanks for the replies
 
Upvote 0

Smee

Well-Known Member
Licensed User
Longtime User
Erel,
I do not understand what you mean

The code that executes is as follows

B4X:
   If FirstTime=True Then
      Activity.LoadLayout("Menu")
      pnlMenu.Visible=True
      SQL.Initialize(File.DirInternal, "WDOrders.db", True)

when the code gets to the initalise statement i get the following error


android.database.sqlite.SQLiteDatabaseCorruptException: database disk image is malformed: , while compiling: PRAGMA journal_mode=TRUNCATE
 
Upvote 0

Smee

Well-Known Member
Licensed User
Longtime User
Your database was created with an SQLite version that is not compatible with the version running on this device (SQLite engine is part of the OS).

The difference is in the JOURNAL mode used. Where did you create this database?

It WAS created ON the Device

B4X:
Sub Activity_Create(FirstTime As Boolean)
   ProgressDialogShow("Building Database")
      SQL.Initialize(File.DirInternal, "WDOrders.db", True)
      CreateTables


Sub CreateTables(TableName As String)

   SQL.ExecNonQuery("CREATE TABLE PicturesLink (CatNum INTEGER,PageNum INTEGER,DirName TEXT,Picture TEXT,ProductName TEXT)")
   SQL.ExecNonQuery("CREATE TABLE Customers (CustCode TEXT , CustName TEXT, Address TEXT, Suburb TEXT, Phone TEXT)")
    SQL.ExecNonQuery("CREATE TABLE Orders (Date TEXT, CustCode TEXT,ProdCode TEXT,Qty INTEGER,Cost SINGLE,Sent INTEGER)") 
    SQL.ExecNonQuery("CREATE TABLE Products (ProdCode TEXT,Description TEXT,Price1 SINGLE,Price2 SINGLE,Qis INT,Moq INT,Roq INT)") 
.....
.....
 
Upvote 0

luke2012

Well-Known Member
Licensed User
Longtime User
Erel,
I have the same error on :

Model : Samsung GT-P1010
Android ver. : 2.2.1

It's related to the Android version?
 
Upvote 0

luke2012

Well-Known Member
Licensed User
Longtime User
Yes I include the db within my app.
I check the developer consolle and i'll let you known.

Thanks!
 
Upvote 0
Top