Android uses SQLite, so your questions are really about how SQLite behaves.
 On their web site, a relevant part might be:

http://www.sqlite.org/faq.html#q19

On Tue, May 11, 2010 at 11:45 AM, Tomei Ningen <tomei.nin...@yahoo.com>wrote:

> Hello,
>
> I have an app that stores a database on SD card.
>
> If I don't use beginTransaction/endTransaction, does Android have any
> guarantee about the the contents of a database when power is lost? For
> example, if I have code like this:
>
>              //db.beginTransaction();
>              //try {
>                    db.delete(TABLE_NAME, "id=123", null);
>                    System.out.println("Deleted 123");
>
>                    db.delete(TABLE_NAME, "id=456", null);
>                    System.out.println("Deleted 456");
>
>              //    db.setTransactionSuccessful();
>              //} finally {
>              //     db.endTransaction();
>              //}
>
> and the database is in SD card.
>
> When I randomly pull the SD card from the phone, is any of the
> following guaranteed to be true if I insert the SD card again and
> reload the database:
>
> (1) Order of deletion -- if id=456 has been deleted, then id=123 must
> have been deleted.
>
> (2) Immediacy of commit -- if I see the message "Deleted 123" from
> logcat, then id=123 must have been deleted.
>
> (3) Non corruption -- rows that are unrelated to id=123 and id=456 are
> guaranteed to remain in the database regardless
>
> Note that I am not using transactions because I don't need the two
> rows to be atomically deleted. However, I do not want the user has any
> surprises -- if I tell them a row has been deleted, then this row
> should not appear again when the user re-inserts the SD card.
>
> Thanks!
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>



-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to