public static synchronized List<Transaction> getTransactions(Context context, String itemId) {
   BillingDB db = new BillingDB(context);
   final Cursor c = db.queryTransactions(itemId);
   final List<Transaction> transactions = cursorToList(c);
   db.close();
   return transactions;
 }
 public static synchronized int countPurchases(Context context, String itemId) {
   BillingDB db = new BillingDB(context);
   final Cursor c = db.queryTransactions(itemId, PurchaseState.PURCHASED);
   int count = 0;
   if (c != null) {
     count = c.getCount();
     c.close();
   }
   db.close();
   return count;
 }
 private static List<Transaction> cursorToList(final Cursor c) {
   final List<Transaction> transactions = new ArrayList<Transaction>();
   if (c != null) {
     while (c.moveToNext()) {
       final Transaction purchase = BillingDB.createTransaction(c);
       transactions.add(purchase);
     }
     c.close();
   }
   return transactions;
 }
 public static synchronized void addTransaction(Context context, Transaction transaction) {
   BillingDB db = new BillingDB(context);
   db.insert(transaction);
   db.close();
 }