VCardComposer.java revision da2f6ef422b360827f2c5231552d8c9fad0ed8b1
1/* 2 * Copyright (C) 2009 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 * use this file except in compliance with the License. You may obtain a copy of 6 * the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 * License for the specific language governing permissions and limitations under 14 * the License. 15 */ 16package com.android.vcard; 17 18import com.android.vcard.exception.VCardException; 19 20import android.content.ContentResolver; 21import android.content.ContentValues; 22import android.content.Context; 23import android.content.Entity; 24import android.content.Entity.NamedContentValues; 25import android.content.EntityIterator; 26import android.database.Cursor; 27import android.database.sqlite.SQLiteException; 28import android.net.Uri; 29import android.provider.ContactsContract.CommonDataKinds.Email; 30import android.provider.ContactsContract.CommonDataKinds.Event; 31import android.provider.ContactsContract.CommonDataKinds.Im; 32import android.provider.ContactsContract.CommonDataKinds.Nickname; 33import android.provider.ContactsContract.CommonDataKinds.Note; 34import android.provider.ContactsContract.CommonDataKinds.Organization; 35import android.provider.ContactsContract.CommonDataKinds.Phone; 36import android.provider.ContactsContract.CommonDataKinds.Photo; 37import android.provider.ContactsContract.CommonDataKinds.Relation; 38import android.provider.ContactsContract.CommonDataKinds.SipAddress; 39import android.provider.ContactsContract.CommonDataKinds.StructuredName; 40import android.provider.ContactsContract.CommonDataKinds.StructuredPostal; 41import android.provider.ContactsContract.CommonDataKinds.Website; 42import android.provider.ContactsContract.Contacts; 43import android.provider.ContactsContract.Data; 44import android.provider.ContactsContract.RawContacts; 45import android.provider.ContactsContract.RawContactsEntity; 46import android.text.TextUtils; 47import android.util.CharsetUtils; 48import android.util.Log; 49 50import java.io.BufferedWriter; 51import java.io.FileOutputStream; 52import java.io.IOException; 53import java.io.OutputStream; 54import java.io.OutputStreamWriter; 55import java.io.UnsupportedEncodingException; 56import java.io.Writer; 57import java.lang.reflect.InvocationTargetException; 58import java.lang.reflect.Method; 59import java.nio.charset.UnsupportedCharsetException; 60import java.util.ArrayList; 61import java.util.HashMap; 62import java.util.List; 63import java.util.Map; 64 65/** 66 * <p> 67 * The class for composing vCard from Contacts information. 68 * </p> 69 * <p> 70 * Usually, this class should be used like this. 71 * </p> 72 * <pre class="prettyprint">VCardComposer composer = null; 73 * try { 74 * composer = new VCardComposer(context); 75 * composer.addHandler( 76 * composer.new HandlerForOutputStream(outputStream)); 77 * if (!composer.init()) { 78 * // Do something handling the situation. 79 * return; 80 * } 81 * while (!composer.isAfterLast()) { 82 * if (mCanceled) { 83 * // Assume a user may cancel this operation during the export. 84 * return; 85 * } 86 * if (!composer.createOneEntry()) { 87 * // Do something handling the error situation. 88 * return; 89 * } 90 * } 91 * } finally { 92 * if (composer != null) { 93 * composer.terminate(); 94 * } 95 * }</pre> 96 * <p> 97 * Users have to manually take care of memory efficiency. Even one vCard may contain 98 * image of non-trivial size for mobile devices. 99 * </p> 100 * <p> 101 * {@link VCardBuilder} is used to build each vCard. 102 * </p> 103 */ 104public class VCardComposer { 105 private static final String LOG_TAG = "VCardComposer"; 106 107 public static final String FAILURE_REASON_FAILED_TO_GET_DATABASE_INFO = 108 "Failed to get database information"; 109 110 public static final String FAILURE_REASON_NO_ENTRY = 111 "There's no exportable in the database"; 112 113 public static final String FAILURE_REASON_NOT_INITIALIZED = 114 "The vCard composer object is not correctly initialized"; 115 116 /** Should be visible only from developers... (no need to translate, hopefully) */ 117 public static final String FAILURE_REASON_UNSUPPORTED_URI = 118 "The Uri vCard composer received is not supported by the composer."; 119 120 public static final String NO_ERROR = "No error"; 121 122 public static final String VCARD_TYPE_STRING_DOCOMO = "docomo"; 123 124 // Strictly speaking, "Shift_JIS" is the most appropriate, but we use upper version here, 125 // since usual vCard devices for Japanese devices already use it. 126 private static final String SHIFT_JIS = "SHIFT_JIS"; 127 private static final String UTF_8 = "UTF-8"; 128 129 /** 130 * Special URI for testing. 131 */ 132 public static final String VCARD_TEST_AUTHORITY = "com.android.unit_tests.vcard"; 133 public static final Uri VCARD_TEST_AUTHORITY_URI = 134 Uri.parse("content://" + VCARD_TEST_AUTHORITY); 135 public static final Uri CONTACTS_TEST_CONTENT_URI = 136 Uri.withAppendedPath(VCARD_TEST_AUTHORITY_URI, "contacts"); 137 138 private static final Map<Integer, String> sImMap; 139 140 static { 141 sImMap = new HashMap<Integer, String>(); 142 sImMap.put(Im.PROTOCOL_AIM, VCardConstants.PROPERTY_X_AIM); 143 sImMap.put(Im.PROTOCOL_MSN, VCardConstants.PROPERTY_X_MSN); 144 sImMap.put(Im.PROTOCOL_YAHOO, VCardConstants.PROPERTY_X_YAHOO); 145 sImMap.put(Im.PROTOCOL_ICQ, VCardConstants.PROPERTY_X_ICQ); 146 sImMap.put(Im.PROTOCOL_JABBER, VCardConstants.PROPERTY_X_JABBER); 147 sImMap.put(Im.PROTOCOL_SKYPE, VCardConstants.PROPERTY_X_SKYPE_USERNAME); 148 // We don't add Google talk here since it has to be handled separately. 149 } 150 151 public static interface OneEntryHandler { 152 public boolean onInit(Context context); 153 public boolean onEntryCreated(String vcard); 154 public void onTerminate(); 155 } 156 157 /** 158 * <p> 159 * An useful handler for emitting vCard String to an OutputStream object one by one. 160 * </p> 161 * <p> 162 * The input OutputStream object is closed() on {@link #onTerminate()}. 163 * Must not close the stream outside this class. 164 * </p> 165 */ 166 public final class HandlerForOutputStream implements OneEntryHandler { 167 @SuppressWarnings("hiding") 168 private static final String LOG_TAG = "VCardComposer.HandlerForOutputStream"; 169 170 private boolean mOnTerminateIsCalled = false; 171 172 private final OutputStream mOutputStream; // mWriter will close this. 173 private Writer mWriter; 174 175 /** 176 * Input stream will be closed on the detruction of this object. 177 */ 178 public HandlerForOutputStream(final OutputStream outputStream) { 179 mOutputStream = outputStream; 180 } 181 182 @Override 183 public boolean onInit(final Context context) { 184 try { 185 mWriter = new BufferedWriter(new OutputStreamWriter( 186 mOutputStream, mCharset)); 187 } catch (UnsupportedEncodingException e1) { 188 Log.e(LOG_TAG, "Unsupported charset: " + mCharset); 189 mErrorReason = "Encoding is not supported (usually this does not happen!): " 190 + mCharset; 191 return false; 192 } 193 194 if (mIsDoCoMo) { 195 try { 196 // Create one empty entry. 197 mWriter.write(createOneEntryInternal("-1", null)); 198 } catch (VCardException e) { 199 Log.e(LOG_TAG, "VCardException has been thrown during on Init(): " + 200 e.getMessage()); 201 return false; 202 } catch (IOException e) { 203 Log.e(LOG_TAG, 204 "IOException occurred during exportOneContactData: " 205 + e.getMessage()); 206 mErrorReason = "IOException occurred: " + e.getMessage(); 207 return false; 208 } 209 } 210 return true; 211 } 212 213 @Override 214 public boolean onEntryCreated(String vcard) { 215 try { 216 mWriter.write(vcard); 217 } catch (IOException e) { 218 Log.e(LOG_TAG, 219 "IOException occurred during exportOneContactData: " 220 + e.getMessage()); 221 mErrorReason = "IOException occurred: " + e.getMessage(); 222 return false; 223 } 224 return true; 225 } 226 227 @Override 228 public void onTerminate() { 229 mOnTerminateIsCalled = true; 230 if (mWriter != null) { 231 try { 232 // Flush and sync the data so that a user is able to pull 233 // the SDCard just after 234 // the export. 235 mWriter.flush(); 236 if (mOutputStream != null 237 && mOutputStream instanceof FileOutputStream) { 238 ((FileOutputStream) mOutputStream).getFD().sync(); 239 } 240 } catch (IOException e) { 241 Log.d(LOG_TAG, 242 "IOException during closing the output stream: " 243 + e.getMessage()); 244 } finally { 245 closeOutputStream(); 246 } 247 } 248 } 249 250 public void closeOutputStream() { 251 try { 252 mWriter.close(); 253 } catch (IOException e) { 254 Log.w(LOG_TAG, "IOException is thrown during close(). Ignoring."); 255 } 256 } 257 258 @Override 259 public void finalize() { 260 if (!mOnTerminateIsCalled) { 261 onTerminate(); 262 } 263 } 264 } 265 266 private final Context mContext; 267 private final int mVCardType; 268 private final boolean mCareHandlerErrors; 269 private final ContentResolver mContentResolver; 270 271 private final boolean mIsDoCoMo; 272 private Cursor mCursor; 273 private int mIdColumn; 274 275 private final String mCharset; 276 private boolean mTerminateIsCalled; 277 private final List<OneEntryHandler> mHandlerList; 278 279 private String mErrorReason = NO_ERROR; 280 281 private static final String[] sContactsProjection = new String[] { 282 Contacts._ID, 283 }; 284 285 public VCardComposer(Context context) { 286 this(context, VCardConfig.VCARD_TYPE_DEFAULT, null, true); 287 } 288 289 /** 290 * The variant which sets charset to null and sets careHandlerErrors to true. 291 */ 292 public VCardComposer(Context context, int vcardType) { 293 this(context, vcardType, null, true); 294 } 295 296 public VCardComposer(Context context, int vcardType, String charset) { 297 this(context, vcardType, charset, true); 298 } 299 300 /** 301 * The variant which sets charset to null. 302 */ 303 public VCardComposer(final Context context, final int vcardType, 304 final boolean careHandlerErrors) { 305 this(context, vcardType, null, careHandlerErrors); 306 } 307 308 /** 309 * Construct for supporting call log entry vCard composing. 310 * 311 * @param context Context to be used during the composition. 312 * @param vcardType The type of vCard, typically available via {@link VCardConfig}. 313 * @param charset The charset to be used. Use null when you don't need the charset. 314 * @param careHandlerErrors If true, This object returns false everytime 315 * a Handler object given via {{@link #addHandler(OneEntryHandler)} returns false. 316 * If false, this ignores those errors. 317 */ 318 public VCardComposer(final Context context, final int vcardType, String charset, 319 final boolean careHandlerErrors) { 320 mContext = context; 321 mVCardType = vcardType; 322 mCareHandlerErrors = careHandlerErrors; 323 mContentResolver = context.getContentResolver(); 324 325 mIsDoCoMo = VCardConfig.isDoCoMo(vcardType); 326 mHandlerList = new ArrayList<OneEntryHandler>(); 327 328 charset = (TextUtils.isEmpty(charset) ? VCardConfig.DEFAULT_EXPORT_CHARSET : charset); 329 final boolean shouldAppendCharsetParam = !( 330 VCardConfig.isVersion30(vcardType) && UTF_8.equalsIgnoreCase(charset)); 331 332 if (mIsDoCoMo || shouldAppendCharsetParam) { 333 if (SHIFT_JIS.equalsIgnoreCase(charset)) { 334 if (mIsDoCoMo) { 335 try { 336 charset = CharsetUtils.charsetForVendor(SHIFT_JIS, "docomo").name(); 337 } catch (UnsupportedCharsetException e) { 338 Log.e(LOG_TAG, 339 "DoCoMo-specific SHIFT_JIS was not found. " 340 + "Use SHIFT_JIS as is."); 341 charset = SHIFT_JIS; 342 } 343 } else { 344 try { 345 charset = CharsetUtils.charsetForVendor(SHIFT_JIS).name(); 346 } catch (UnsupportedCharsetException e) { 347 /* Log.e(LOG_TAG, 348 "Career-specific SHIFT_JIS was not found. " 349 + "Use SHIFT_JIS as is."); */ 350 charset = SHIFT_JIS; 351 } 352 } 353 mCharset = charset; 354 } else { 355 /* Log.w(LOG_TAG, 356 "The charset \"" + charset + "\" is used while " 357 + SHIFT_JIS + " is needed to be used."); */ 358 if (TextUtils.isEmpty(charset)) { 359 mCharset = SHIFT_JIS; 360 } else { 361 try { 362 charset = CharsetUtils.charsetForVendor(charset).name(); 363 } catch (UnsupportedCharsetException e) { 364 Log.i(LOG_TAG, 365 "Career-specific \"" + charset + "\" was not found (as usual). " 366 + "Use it as is."); 367 } 368 mCharset = charset; 369 } 370 } 371 } else { 372 if (TextUtils.isEmpty(charset)) { 373 mCharset = UTF_8; 374 } else { 375 try { 376 charset = CharsetUtils.charsetForVendor(charset).name(); 377 } catch (UnsupportedCharsetException e) { 378 Log.i(LOG_TAG, 379 "Career-specific \"" + charset + "\" was not found (as usual). " 380 + "Use it as is."); 381 } 382 mCharset = charset; 383 } 384 } 385 386 Log.d(LOG_TAG, "Use the charset \"" + mCharset + "\""); 387 } 388 389 /** 390 * Must be called before {@link #init()}. 391 */ 392 public void addHandler(OneEntryHandler handler) { 393 if (handler != null) { 394 mHandlerList.add(handler); 395 } 396 } 397 398 /** 399 * @return Returns true when initialization is successful and all the other 400 * methods are available. Returns false otherwise. 401 */ 402 public boolean init() { 403 return init(null, null); 404 } 405 406 public boolean init(final String selection, final String[] selectionArgs) { 407 return init(Contacts.CONTENT_URI, selection, selectionArgs, null); 408 } 409 410 /** 411 * Note that this is unstable interface, may be deleted in the future. 412 */ 413 public boolean init(final Uri contentUri, final String selection, 414 final String[] selectionArgs, final String sortOrder) { 415 if (contentUri == null) { 416 return false; 417 } 418 419 if (mCareHandlerErrors) { 420 final List<OneEntryHandler> finishedList = new ArrayList<OneEntryHandler>( 421 mHandlerList.size()); 422 for (OneEntryHandler handler : mHandlerList) { 423 if (!handler.onInit(mContext)) { 424 for (OneEntryHandler finished : finishedList) { 425 finished.onTerminate(); 426 } 427 return false; 428 } 429 } 430 } else { 431 // Just ignore the false returned from onInit(). 432 for (OneEntryHandler handler : mHandlerList) { 433 handler.onInit(mContext); 434 } 435 } 436 437 final String[] projection; 438 if (Contacts.CONTENT_URI.equals(contentUri) || 439 CONTACTS_TEST_CONTENT_URI.equals(contentUri)) { 440 projection = sContactsProjection; 441 } else { 442 mErrorReason = FAILURE_REASON_UNSUPPORTED_URI; 443 return false; 444 } 445 mCursor = mContentResolver.query( 446 contentUri, projection, selection, selectionArgs, sortOrder); 447 448 if (mCursor == null) { 449 mErrorReason = FAILURE_REASON_FAILED_TO_GET_DATABASE_INFO; 450 return false; 451 } 452 453 if (getCount() == 0 || !mCursor.moveToFirst()) { 454 try { 455 mCursor.close(); 456 } catch (SQLiteException e) { 457 Log.e(LOG_TAG, "SQLiteException on Cursor#close(): " + e.getMessage()); 458 } finally { 459 mCursor = null; 460 mErrorReason = FAILURE_REASON_NO_ENTRY; 461 } 462 return false; 463 } 464 465 mIdColumn = mCursor.getColumnIndex(Contacts._ID); 466 467 return true; 468 } 469 470 public boolean createOneEntry() { 471 return createOneEntry(null); 472 } 473 474 /** 475 * @param getEntityIteratorMethod For Dependency Injection. 476 * @hide just for testing. 477 */ 478 public boolean createOneEntry(Method getEntityIteratorMethod) { 479 if (mCursor == null || mCursor.isAfterLast()) { 480 mErrorReason = FAILURE_REASON_NOT_INITIALIZED; 481 return false; 482 } 483 final String vcard; 484 try { 485 if (mIdColumn >= 0) { 486 vcard = createOneEntryInternal(mCursor.getString(mIdColumn), 487 getEntityIteratorMethod); 488 } else { 489 Log.e(LOG_TAG, "Incorrect mIdColumn: " + mIdColumn); 490 return true; 491 } 492 } catch (VCardException e) { 493 Log.e(LOG_TAG, "VCardException has been thrown: " + e.getMessage()); 494 return false; 495 } catch (OutOfMemoryError error) { 496 // Maybe some data (e.g. photo) is too big to have in memory. But it 497 // should be rare. 498 Log.e(LOG_TAG, "OutOfMemoryError occured. Ignore the entry."); 499 System.gc(); 500 // TODO: should tell users what happened? 501 return true; 502 } finally { 503 mCursor.moveToNext(); 504 } 505 506 // This function does not care the OutOfMemoryError on the handler side :-P 507 if (mCareHandlerErrors) { 508 List<OneEntryHandler> finishedList = new ArrayList<OneEntryHandler>( 509 mHandlerList.size()); 510 for (OneEntryHandler handler : mHandlerList) { 511 if (!handler.onEntryCreated(vcard)) { 512 return false; 513 } 514 } 515 } else { 516 for (OneEntryHandler handler : mHandlerList) { 517 handler.onEntryCreated(vcard); 518 } 519 } 520 521 return true; 522 } 523 524 private String createOneEntryInternal(final String contactId, 525 final Method getEntityIteratorMethod) throws VCardException { 526 final Map<String, List<ContentValues>> contentValuesListMap = 527 new HashMap<String, List<ContentValues>>(); 528 // The resolver may return the entity iterator with no data. It is possible. 529 // e.g. If all the data in the contact of the given contact id are not exportable ones, 530 // they are hidden from the view of this method, though contact id itself exists. 531 EntityIterator entityIterator = null; 532 try { 533 final Uri uri = RawContactsEntity.CONTENT_URI.buildUpon() 534 // .appendQueryParameter("for_export_only", "1") 535 .appendQueryParameter(Data.FOR_EXPORT_ONLY, "1") 536 .build(); 537 final String selection = Data.CONTACT_ID + "=?"; 538 final String[] selectionArgs = new String[] {contactId}; 539 if (getEntityIteratorMethod != null) { 540 // Please note that this branch is executed by unit tests only 541 try { 542 entityIterator = (EntityIterator)getEntityIteratorMethod.invoke(null, 543 mContentResolver, uri, selection, selectionArgs, null); 544 } catch (IllegalArgumentException e) { 545 Log.e(LOG_TAG, "IllegalArgumentException has been thrown: " + 546 e.getMessage()); 547 } catch (IllegalAccessException e) { 548 Log.e(LOG_TAG, "IllegalAccessException has been thrown: " + 549 e.getMessage()); 550 } catch (InvocationTargetException e) { 551 Log.e(LOG_TAG, "InvocationTargetException has been thrown: "); 552 StackTraceElement[] stackTraceElements = e.getCause().getStackTrace(); 553 for (StackTraceElement element : stackTraceElements) { 554 Log.e(LOG_TAG, " at " + element.toString()); 555 } 556 throw new VCardException("InvocationTargetException has been thrown: " + 557 e.getCause().getMessage()); 558 } 559 } else { 560 entityIterator = RawContacts.newEntityIterator(mContentResolver.query( 561 uri, null, selection, selectionArgs, null)); 562 } 563 564 if (entityIterator == null) { 565 Log.e(LOG_TAG, "EntityIterator is null"); 566 return ""; 567 } 568 569 if (!entityIterator.hasNext()) { 570 Log.w(LOG_TAG, "Data does not exist. contactId: " + contactId); 571 return ""; 572 } 573 574 while (entityIterator.hasNext()) { 575 Entity entity = entityIterator.next(); 576 for (NamedContentValues namedContentValues : entity.getSubValues()) { 577 ContentValues contentValues = namedContentValues.values; 578 String key = contentValues.getAsString(Data.MIMETYPE); 579 if (key != null) { 580 List<ContentValues> contentValuesList = 581 contentValuesListMap.get(key); 582 if (contentValuesList == null) { 583 contentValuesList = new ArrayList<ContentValues>(); 584 contentValuesListMap.put(key, contentValuesList); 585 } 586 contentValuesList.add(contentValues); 587 } 588 } 589 } 590 } finally { 591 if (entityIterator != null) { 592 entityIterator.close(); 593 } 594 } 595 596 return buildVCard(contentValuesListMap); 597 } 598 599 /** 600 * Builds and returns vCard using given map, whose key is CONTENT_ITEM_TYPE defined in 601 * {ContactsContract}. Developers can override this method to customize the output. 602 */ 603 public String buildVCard(final Map<String, List<ContentValues>> contentValuesListMap) { 604 if (contentValuesListMap == null) { 605 Log.e(LOG_TAG, "The given map is null. Ignore and return empty String"); 606 return ""; 607 } else { 608 final VCardBuilder builder = new VCardBuilder(mVCardType, mCharset); 609 builder.appendNameProperties(contentValuesListMap.get(StructuredName.CONTENT_ITEM_TYPE)) 610 .appendNickNames(contentValuesListMap.get(Nickname.CONTENT_ITEM_TYPE)) 611 .appendPhones(contentValuesListMap.get(Phone.CONTENT_ITEM_TYPE)) 612 .appendEmails(contentValuesListMap.get(Email.CONTENT_ITEM_TYPE)) 613 .appendPostals(contentValuesListMap.get(StructuredPostal.CONTENT_ITEM_TYPE)) 614 .appendOrganizations(contentValuesListMap.get(Organization.CONTENT_ITEM_TYPE)) 615 .appendWebsites(contentValuesListMap.get(Website.CONTENT_ITEM_TYPE)); 616 if ((mVCardType & VCardConfig.FLAG_REFRAIN_IMAGE_EXPORT) == 0) { 617 builder.appendPhotos(contentValuesListMap.get(Photo.CONTENT_ITEM_TYPE)); 618 } 619 builder.appendNotes(contentValuesListMap.get(Note.CONTENT_ITEM_TYPE)) 620 .appendEvents(contentValuesListMap.get(Event.CONTENT_ITEM_TYPE)) 621 .appendIms(contentValuesListMap.get(Im.CONTENT_ITEM_TYPE)) 622 .appendSipAddresses(contentValuesListMap.get(SipAddress.CONTENT_ITEM_TYPE)) 623 .appendRelation(contentValuesListMap.get(Relation.CONTENT_ITEM_TYPE)); 624 return builder.toString(); 625 } 626 } 627 628 public void terminate() { 629 for (OneEntryHandler handler : mHandlerList) { 630 handler.onTerminate(); 631 } 632 633 if (mCursor != null) { 634 try { 635 mCursor.close(); 636 } catch (SQLiteException e) { 637 Log.e(LOG_TAG, "SQLiteException on Cursor#close(): " + e.getMessage()); 638 } 639 mCursor = null; 640 } 641 642 mTerminateIsCalled = true; 643 } 644 645 @Override 646 public void finalize() { 647 if (!mTerminateIsCalled) { 648 Log.w(LOG_TAG, "terminate() is not called yet. We call it in finalize() step."); 649 terminate(); 650 } 651 } 652 653 /** 654 * @return returns the number of available entities. The return value is undefined 655 * when this object is not ready yet (typically when {{@link #init()} is not called 656 * or when {@link #terminate()} is already called). 657 */ 658 public int getCount() { 659 if (mCursor == null) { 660 Log.w(LOG_TAG, "This object is not ready yet."); 661 return 0; 662 } 663 return mCursor.getCount(); 664 } 665 666 /** 667 * @return true when there's no entity to be built. The return value is undefined 668 * when this object is not ready yet. 669 */ 670 public boolean isAfterLast() { 671 if (mCursor == null) { 672 Log.w(LOG_TAG, "This object is not ready yet."); 673 return false; 674 } 675 return mCursor.isAfterLast(); 676 } 677 678 /** 679 * @return Returns the error reason. 680 */ 681 public String getErrorReason() { 682 return mErrorReason; 683 } 684} 685