1. Does having the journal file in the database folder on the device mean that the database was not exited properly by not closing the SQL object?.
2. What does it exactly mean if there is a journal file and its size is 0 B
3. What does it exactly mean if there is a journal file and its size is say 500 KB
4. If you have one common database used by several applications that you migrate from one to the other not through startactivity, but through intent frequently, is there any need to close the SQL object every time you exit one and enter the other?
5. Do you think the best approach to avoiding a lock database situation is import data into tables from text files when doing an upgrade as opposed to copying an entire database over an existing one, although the latter is more practical.
6. Could you please answer each individually
thanks
1. Means that either a cursor remained open, or a transaction is pending, in general. However,
1 & 2 & 3, This can also happen when we have the database opened by other applications. You can think of it, as many users enter and interact with the same database.
4. You should always close the sql object. Occasionally there can be a db-journal with 0bytes, still it's a good practice to get rid of it. sql.close will do the job, if no pending transactions are there.
5. In general, it is a good approach to create an sql file (be it txt or whatever) forming the necessary update/insert/delete queries and even recreate tables. This is the approach used in import/export in mysql most of the time, instead of a total replacement of the db. After all, there may always be data in our db which we don't wish to alter.
In two of my apps, with many devices acting as clients (in the one of them, I have now 20+ androids running on a android based E.R.P. I made), I found all the above to work well. Please note that before, I had problems mainly due to the causes I described above. So, no matter if it is theoretical correct or not, they worked for me
I am really no expert in the sqlite structure, hope other users here can give more info/knowledge.