8

Maybe someone can share some code example or maybe explain. I use WorkManger Flutter plugin. The idea is to make background task which update sqlite db on device. Plugin works it's executing task but no updates in DB , if I run methods which works with DB directly they work so there is no problem with methods. Look's like I missing something. WorkManager just don't want to work with DB

TomLynx23
  • 113
  • 1
  • 3

1 Answers1

0

If you are still facing this issue, it would be helpful if you could share the code sample in your question.

Meanwhile, you can check if you are establishing or opening the database connection in your background task executable code. It usually looks like this:

@pragma('vm:entry-point')
 void callbackDispatcher() {
  Workmanager().executeTask((task, inputData) {
    debugPrint(
      "Native called background task: $inputData",
    );
    /// open your database connection here
    var db = await openDatabase('my_db.db');
    return Future.value(true);
  });
}

Be sure to share more info if this does not fix the issue. Thanks

Ayesha Iftikhar
  • 358
  • 3
  • 13