0

I am creating a sqlite DB, which need to be exactly same as a sqlite DB created by server which is in c# (the tables, data, size).

I created the DB with same schema and data, but for some reason the size of db don't match. I searched a lot but I could not find any solution or reason for this.

Any comment, Idea or solution will do.

We are using SQLiteOpenHelper for java and SQLiteCommand in .net server.

4
  • Have you tried to dump each file and see what the difference is? stackoverflow.com/questions/2093263/… What code did you use to create the schema, etc. ? Commented Aug 2, 2014 at 15:21
  • Did you set the page size? Commented Aug 2, 2014 at 15:53
  • Hi @tim yes I saw the files, Java has a lot of 0's in it. Commented Aug 3, 2014 at 7:01
  • Hi @CL No we did not set any page size. Commented Aug 3, 2014 at 7:02

1 Answer 1

0

SQLite aligns most major data structures onto pages, so the database page size has a big influence on the file size.

SQLite attempts to align the default page size with the disk sector size, but this works differently on different operating system.

If you want the page size to be consistent, set it with PRAGMA page_size when creating the database.

Sign up to request clarification or add additional context in comments.

4 Comments

Yes this seems to the problem, in java I am getting the page size as 4096 while in c# it's 1024. The db file sizes are also roughly 4 times more in java. So I am trying to set page size using db.rawQuery("PRAGMA page_size=1024",null); but it just doesn't seems to work. I have also tried the setPageSize method provided by SQLiteOpenHelper. Do you have any idea why?. I have added these lines in onCreate, onConfigure, onOpen its not working.
You would have set it before SQLiteOpenHelper starts its transaction. Use something like SQLiteAssetHelper to copy a database file that already has the right page size.
I don't have any DB with the right size. And in SQLiteOpenHelper object I am not doing any transaction other than creating the db (which needs to be done as this is how I will get the db to set the page size)
SQLiteOpenHelper itself creates a transaction to run the callbacks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.