Android BackUp API: How to perform database backups/restore thread safe?

时间:2016-08-31 18:36:22

标签: android-sqlite android-database android-backup-service backup-agent

I want to perform SQLite database backups/restores. I thought the easiest way was to use the BackUp API. However, the documentation says:

However, reading and writing to files on internal storage is not threadsafe. To ensure that your backup agent does not read or write your files at the same time as your activities, you must use synchronized statements each time you perform a read or write. For example, in any Activity where you read and write the file, you need an object to use as the intrinsic lock for the synchronized statements:

How can I perform database backups/restore thread safe?

0 个答案:

没有答案