1

In my Android application, I need to add about 300 customers. As application have database import/export feature available so I decided to do insert customers on computer, instead of mobile.

Here's how I did that:

  1. Install app on mobile
  2. Exported db using export feature
  3. Inserted data using SQLite Editor tool
  4. Saved the DB
  5. Transferred on mobile and imported back

Logically, it should work but it's not working.

Export/Import Feature:

This feature does work as expected, I've tested like this:

  1. Added some dummy data
  2. Exported data on SD card
  3. Delete the App
  4. Re-install (dummy data wasn't available)
  5. Imported data back and it worked

What I noticed:

  1. The exported database zip file contains a file with same name as database but with an additional word e.g DBNAME.db-journal. When I added data in db using SQLite Editor, and save it. The -journal file was removed.

  2. As application doesn't show added data in app, but if we export db from app and open it in editor, then it shows all data.

I've even tried to remove previous -journal file, right before importing but no luck.

halfer
  • 19,824
  • 17
  • 99
  • 186
Alena
  • 1,134
  • 6
  • 19
  • 45
  • `"SQFLite database is not showing data in application"` post the relevant code of that application – pskink Nov 16 '19 at 07:30
  • There's a lot of code, it won't be easy for anyone to just make it work because it depends on a lot of classes, libraries and I can't share entire app code. Please tell me, which part of code should I share? – Alena Nov 16 '19 at 07:33
  • where you use [query](https://pub.dev/documentation/sqflite/latest/sqlite_api/DatabaseExecutor/query.html) method – pskink Nov 16 '19 at 07:37
  • There are a lot of `db.query` statements, here is a sample statement which gets cities. `await db.query('cities', where: 'state = ?', whereArgs: [state], orderBy: 'name ASC')` – Alena Nov 16 '19 at 07:45
  • I'd have looked into the sqflite source code to see exactly what files are being written and read from. – zeekhuge Nov 16 '19 at 09:44
  • @ZeekHuge I don't understand; what exactly you need. I've already mentioned, the Import/Export feature works as expected, but the problem occur, when we export database and modify using any other tool. In other words, when the `.db-journal` file is not available. – Alena Nov 16 '19 at 15:11
  • actually i am lost, what is your problem actually? your app opens your database but it is empty (even if you see some data using `sqlite3` tool)? what you see if you enter `.dump` command using `sqlite3` (lets say, first 10 lines)? – pskink Nov 17 '19 at 06:47
  • should I run that command on mobile OR machine and how? (any example) I was using GUI based tool called "DB Browser for SQLite" – Alena Nov 18 '19 at 14:24

0 Answers0