0

I have a huge XML file (more than 20 Mb) and I can't change its format. It represents DB. In fixed periods of time it can change and I must update all changed data on a device.

I am using SyncAdapter to transfer a huge amount of data from XML to SQLite via ContentProvider. I can't use applyBatch(), because I can't keep all the data in the memory, I want to use the following approach:

  1. Start nonExclusiveTransaction

  2. I want to clear all of the tables in DB (Searching for deleted, updated and created records is slow.)

  3. Parse XML using SAX parser and insert rows as soon as they appear

  4. Commit transaction

I can't find a way to begin and commit a transaction outside ContentProvider. Should I look for a different way to save records in ContentProvider from a 20 Mb XML file?

Zong
  • 6,160
  • 5
  • 32
  • 46

1 Answers1

0

You can get reference to your ContentProvider implementation by calling

acquireContentProviderClient(authority)

Look at this SO answer

After that just cast object that acquireContentProviderClient returns to your custom ContentProvider and call your methods that start and end transactions.

Community
  • 1
  • 1