| 1511 | } |
| 1512 | |
| 1513 | synchronized public boolean saveFileInfos(Collection<FileInfo> list) |
| 1514 | { |
| 1515 | Log.v("cr3db", "save BookInfo collection: " + list.size() + " items"); |
| 1516 | if ( mDB==null ) { |
| 1517 | Log.e("cr3db", "cannot save book info : DB is closed"); |
| 1518 | return false; |
| 1519 | } |
| 1520 | boolean res = true; |
| 1521 | int updateCount = 0; |
| 1522 | try { |
| 1523 | mDB.beginTransaction(); |
| 1524 | for (FileInfo fileInfo : list) { |
| 1525 | if (save(fileInfo)) |
| 1526 | updateCount++; |
| 1527 | } |
| 1528 | mDB.setTransactionSuccessful(); |
| 1529 | } catch (SQLiteException e) { |
| 1530 | L.e("Exception while saving to DB", e); |
| 1531 | res = false; |
| 1532 | } finally { |
| 1533 | try { |
| 1534 | Log.v("cr3db", "BookInfo : committing " + updateCount + " updated books"); |
| 1535 | long start = android.os.SystemClock.uptimeMillis(); |
| 1536 | mDB.endTransaction(); |
| 1537 | long duration = android.os.SystemClock.uptimeMillis() - start; |
| 1538 | Log.v("cr3db", "BookInfo collection saved: " + updateCount + " items in " + duration + " ms"); |
| 1539 | } catch (Exception e) { |
| 1540 | L.e("Exception while committing transaction", e); |
| 1541 | } |
| 1542 | } |
| 1543 | return res; |
| 1544 | } |
| 1545 | |
| 1546 | synchronized public void flush() |
| 1547 | { |