Back to project page sugar.
The source code is released under:
Copyright (C) 2012 by Satya Narayan Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the S...
If you think the Android project sugar listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.orm; //from w w w . jav a 2 s .c o m import android.database.sqlite.SQLiteDatabase; import android.util.Log; public class SugarTransactionHelper { public static void doInTansaction(SugarTransactionHelper.Callback callback) { SQLiteDatabase database = SugarContext.getSugarContext().getSugarDb().getDB(); database.beginTransaction(); try { Log.d(SugarTransactionHelper.class.getSimpleName(), "Callback executing within transaction"); callback.manipulateInTransaction(); database.setTransactionSuccessful(); Log.d(SugarTransactionHelper.class.getSimpleName(), "Callback successfully executed within transaction"); } catch (Throwable e) { Log.d(SugarTransactionHelper.class.getSimpleName(), "Could execute callback within transaction", e); } finally { database.endTransaction(); } } public static interface Callback { void manipulateInTransaction(); } }