Example usage for java.io SyncFailedException printStackTrace

List of usage examples for java.io SyncFailedException printStackTrace

Introduction

In this page you can find the example usage for java.io SyncFailedException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:au.org.ala.delta.io.BinFile.java

/**
 * Forces the contents of this file to be written to disk.
 *///  w w  w  .j ava 2  s . co  m
public void commit() {

    try {
        // _file.getFD().sync();
        _channel.force(false);
    } catch (SyncFailedException e) {
        // TODO uhoh, what do we do if the sync fails... (i am not sure why
        // it would)
        e.printStackTrace();
    } catch (IOException e) {
        // TODO mmm file descriptor was null - that is bad.
        e.printStackTrace();
    }
    if (_fileMode == BinFileMode.FM_TEMPORARY) {
        _fileMode = BinFileMode.FM_EXISTING;
    }
}

From source file:org.linphone.ContactEditorFragment.java

private void setContactPhoto() {
    ContentResolver cr = getActivity().getContentResolver();
    Uri updateUri = ContactsContract.Data.CONTENT_URI;

    if (photoToAdd != null) {
        //New contact
        if (isNewContact) {
            ops.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI)
                    .withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID, contactID)
                    .withValue(ContactsContract.Data.MIMETYPE,
                            ContactsContract.CommonDataKinds.Photo.CONTENT_ITEM_TYPE)
                    .withValue(ContactsContract.CommonDataKinds.Photo.PHOTO, photoToAdd).build());
        } else { //update contact picture
            String w = ContactsContract.Data.CONTACT_ID + "='" + contact.getID() + "' AND "
                    + ContactsContract.Data.MIMETYPE + " = '"
                    + ContactsContract.CommonDataKinds.Photo.CONTENT_ITEM_TYPE + "'";

            Cursor queryCursor = cr.query(updateUri, new String[] { ContactsContract.Data._ID }, w, null, null);
            if (queryCursor == null) {
                try {
                    throw new SyncFailedException("EE");
                } catch (SyncFailedException e) {
                    e.printStackTrace();
                }/*from   w w  w  .ja  v  a  2 s. c om*/
            } else {
                if (contact.getPhoto() == null) {
                    String rawContactId = ContactsManager.getInstance().findRawContactID(cr,
                            String.valueOf(contactID));
                    ops.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI)
                            .withValue(ContactsContract.Data.RAW_CONTACT_ID, rawContactId)
                            .withValue(ContactsContract.Data.MIMETYPE,
                                    ContactsContract.CommonDataKinds.Photo.CONTENT_ITEM_TYPE)
                            .withValue(ContactsContract.CommonDataKinds.Photo.PHOTO, photoToAdd).build());
                }

                if (queryCursor.moveToFirst()) { // otherwise no photo
                    int colIdx = queryCursor.getColumnIndex(ContactsContract.Data._ID);
                    long id = queryCursor.getLong(colIdx);

                    ops.add(ContentProviderOperation.newUpdate(ContactsContract.Data.CONTENT_URI)
                            .withSelection(ContactsContract.Data._ID + "= ?",
                                    new String[] { String.valueOf(id) })
                            .withValue(ContactsContract.Data.MIMETYPE,
                                    ContactsContract.CommonDataKinds.Photo.CONTENT_ITEM_TYPE)
                            .withValue(ContactsContract.CommonDataKinds.Photo.PHOTO, photoToAdd).build());
                }
                queryCursor.close();
            }
        }
    }
}