Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation for bulk/batch operations #142

Open
imhoff opened this issue May 6, 2013 · 3 comments
Open

Add documentation for bulk/batch operations #142

imhoff opened this issue May 6, 2013 · 3 comments

Comments

@imhoff
Copy link

imhoff commented May 6, 2013

Add support for multiple database interactions in one transaction. Implementing this will enhance performance while inserting a large amount of data into the database; and reduce the risk of getting a inconsistent database state if the application is closed during long running db operations (rollback).

@imhoff
Copy link
Author

imhoff commented May 6, 2013

Two ways to implement this behavior are possible. By [using](http://developer.android.com/reference/android/content/ContentProvider.html#bulkInsert%28android.net.Uri, android.content.ContentValues[]%29) ContentProvider.bulkInsert(Uri uri, ContentValues[] values) multiple inserts into one table could be chained together. This would be just a minor adjustment to the current code as the basic implementation of bulkInsert is already provided by Android. The limitation of this method is that only inserts for one specific table are chainable.

The second and more complete option is using ContentProvider.applyBatch(ArrayList<ContentProviderOperation> operations)
This approach is neither limited to a single table nor to insert actions only. Unfortunately it is also a lot more complicated.

This question on Stackoverflow suggests using the second approach.

@fluxtah
Copy link
Contributor

fluxtah commented May 6, 2013

This is yettop be documented however Mechaniod can do this, see #121 for details

When I get a moment I will add to docs.

@imhoff
Copy link
Author

imhoff commented May 6, 2013

Thanks man! Had a little look at the classes first but had no clue where to find it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants