private void downloadABook(int position) { boolean isConnected = DaisyBookUtil.getConnectivityStatus(DaisyReaderDownloadBooks.this) != Constants.CONNECT_TYPE_NOT_CONNECTED; IntentController intent = new IntentController(DaisyReaderDownloadBooks.this); if (isConnected) { if (checkFolderIsExist()) { mDaisyBook = mlistDaisyBook.get(position); String link = mDaisyBook.getPath(); if (checkStorage(link) != 0) { String params[] = {link}; runAsynTask(params); } else { intent.pushToDialog( DaisyReaderDownloadBooks.this.getString(R.string.error_not_enough_space), DaisyReaderDownloadBooks.this.getString(R.string.error_title), R.raw.error, false, false, null); } } } else { intent.pushToDialog( DaisyReaderDownloadBooks.this.getString(R.string.error_connect_internet), DaisyReaderDownloadBooks.this.getString(R.string.error_title), R.raw.error, false, false, null); } }
/** * Add a record to RecentBooks table * * @param recentBooks */ public void addRecentBook(DaisyBookInfo recentBooks) { ContentValues mValue = new ContentValues(); mValue.put(NAME_KEY_RECENT_BOOKS, recentBooks.getTitle()); mValue.put(PATH_KEY_RECENT_BOOKS, recentBooks.getPath()); mValue.put(SORT_KEY_RECENT_BOOKS, recentBooks.getSort()); try { SQLiteDatabase mdb = getWritableDatabase(); mdb.insert(TABLE_NAME_RECENT_BOOKS, null, mValue); mdb.close(); } catch (Exception e) { PrivateException ex = new PrivateException(e, mContext); ex.writeLogException(); } }