Example usage for android.database Cursor getCount

List of usage examples for android.database Cursor getCount

Introduction

In this page you can find the example usage for android.database Cursor getCount.

Prototype

int getCount();

Source Link

Document

Returns the numbers of rows in the cursor.

Usage

From source file:com.ichi2.anki.tests.ContentProviderTest.java

/**
 * Check that a valid Cursor is returned when querying notes table with non-default projections
 *//*from  w  ww  . ja v  a 2s  .  com*/
public void testQueryNotesProjection() {
    final ContentResolver cr = getContext().getContentResolver();
    // Query all available notes
    for (int i = 0; i < FlashCardsContract.Note.DEFAULT_PROJECTION.length; i++) {
        String[] projection = removeFromProjection(FlashCardsContract.Note.DEFAULT_PROJECTION, i);
        final Cursor allNotesCursor = cr.query(FlashCardsContract.Note.CONTENT_URI, projection,
                "tag:" + TEST_TAG, null, null);
        assertNotNull("Check that there is a valid cursor", allNotesCursor);
        try {
            assertEquals("Check number of results", mCreatedNotes.size(), allNotesCursor.getCount());
            // Check columns
            assertEquals("Check column count", projection.length, allNotesCursor.getColumnCount());
            for (int j = 0; j < projection.length; j++) {
                assertEquals("Check column name " + j, projection[j], allNotesCursor.getColumnName(j));
            }
        } finally {
            allNotesCursor.close();
        }
    }
}

From source file:org.deviceconnect.android.deviceplugin.chromecast.profile.ChromeCastMediaPlayerProfile.java

/**
 * ?//from   w  w w. j  a v  a 2 s. c o m
 * 
 * @param   mediaType   
 * @param   list        
 * @param   filter      
 * @param   orderBy     
 * @return  ??
 */
private void listupMedia(String mediaType, List<Bundle> list, String filter, String orderBy) {
    Uri uriType = null;

    if (mediaType.equals("Video"))
        uriType = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
    else if (mediaType.equals("Audio"))
        uriType = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
    else if (mediaType.equals("Image"))
        uriType = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;

    ContentResolver mContentResolver = this.getContext().getApplicationContext().getContentResolver();
    Cursor cursorVideo = mContentResolver.query(uriType, null, filter, null, orderBy);
    if (cursorVideo != null) {
        cursorVideo.moveToFirst();
        if (cursorVideo.getCount() > 0) {
            do {
                Bundle medium = new Bundle();
                setMediaInformation(mediaType, medium, cursorVideo);
                list.add(medium);
            } while (cursorVideo.moveToNext());
        }
        cursorVideo.close();
    }
}

From source file:com.ichi2.anki.tests.ContentProviderTest.java

/**
 * Check that updating the flds column works as expected
 *//* w ww  .  j a  va2 s .c o  m*/
public void testUpdateNoteFields() {
    final ContentResolver cr = getContext().getContentResolver();
    ContentValues cv = new ContentValues();
    // Change the fields so that the first field is now "newTestValue"
    String[] dummyFields2 = mDummyFields.clone();
    dummyFields2[0] = TEST_FIELD_VALUE;
    for (Uri uri : mCreatedNotes) {
        // Update the flds
        cv.put(FlashCardsContract.Note.FLDS, Utils.joinFields(dummyFields2));
        cr.update(uri, cv, null, null);
        // Query the table again
        Cursor noteCursor = cr.query(uri, FlashCardsContract.Note.DEFAULT_PROJECTION, null, null, null);
        try {
            assertNotNull("Check that there is a valid cursor for detail data after update", noteCursor);
            assertEquals("Check that there is one and only one entry after update", 1, noteCursor.getCount());
            assertTrue("Move to first item in cursor", noteCursor.moveToFirst());
            String[] newFlds = Utils
                    .splitFields(noteCursor.getString(noteCursor.getColumnIndex(FlashCardsContract.Note.FLDS)));
            assertTrue("Check that the flds have been updated correctly", Arrays.equals(newFlds, dummyFields2));
        } finally {
            noteCursor.close();
        }
    }
}

From source file:com.aniruddhc.acemusic.player.AsyncTasks.AsyncAutoGetAlbumArtTask.java

@Override
protected Void doInBackground(String... params) {

    //First, we'll go through all the songs in the music library DB and get their attributes.
    dbHelper = new DBAccessHelper(mContext);
    String selection = DBAccessHelper.SONG_SOURCE + "<>" + "'GOOGLE_PLAY_MUSIC'";
    String[] projection = { DBAccessHelper._ID, DBAccessHelper.SONG_FILE_PATH, DBAccessHelper.SONG_ALBUM,
            DBAccessHelper.SONG_ARTIST, DBAccessHelper.SONG_TITLE };

    Cursor cursor = dbHelper.getWritableDatabase().query(DBAccessHelper.MUSIC_LIBRARY_TABLE, projection,
            selection, null, null, null, null);

    if (cursor.getCount() != 0) {

        cursor.moveToFirst();/*from   w  w  w  .j a v a 2 s  . c  o  m*/
        dataURIsList.add(cursor.getString(1));
        albumsList.add(cursor.getString(2));
        artistsList.add(cursor.getString(3));

        while (cursor.moveToNext()) {

            dataURIsList.add(cursor.getString(1));
            albumsList.add(cursor.getString(2));
            artistsList.add(cursor.getString(3));
        }

    } else {
        //The user doesn't have any music so let's get outta here.
        return null;
    }

    pd.setMax(dataURIsList.size());

    //Now that we have the attributes of the songs, we'll go through them each and check for missing covers.
    for (int i = 0; i < dataURIsList.size(); i++) {

        try {
            file = new File(dataURIsList.get(i));
        } catch (Exception e) {
            continue;
        }

        audioFile = null;
        try {
            audioFile = AudioFileIO.read(file);
        } catch (CannotReadException e2) {
            // TODO Auto-generated catch block
            continue;
        } catch (IOException e2) {
            // TODO Auto-generated catch block
            continue;
        } catch (TagException e2) {
            // TODO Auto-generated catch block
            continue;
        } catch (ReadOnlyFileException e2) {
            // TODO Auto-generated catch block
            continue;
        } catch (InvalidAudioFrameException e2) {
            // TODO Auto-generated catch block
            continue;
        }

        Tag tag = audioFile.getTag();

        //Set the destination directory for the xml file.
        File SDCardRoot = Environment.getExternalStorageDirectory();
        File xmlFile = new File(SDCardRoot, "albumArt.xml");

        if (tag != null) {

            String title = tag.getFirst(FieldKey.TITLE);
            String checkingMessage = mContext.getResources().getString(R.string.checking_if) + " " + title + " "
                    + mContext.getResources().getString(R.string.has_album_art) + ".";

            currentProgress = currentProgress + 1;
            String[] checkingProgressParams = { checkingMessage, "" + currentProgress };
            publishProgress(checkingProgressParams);

            List<Artwork> artworkList = tag.getArtworkList();

            if (artworkList.size() == 0) {

                //Since the file doesn't have any album artwork, we'll have to download it.
                //Get the artist and album name of the file we're working with.
                String artist = tag.getFirst(FieldKey.ARTIST);
                String album = tag.getFirst(FieldKey.ALBUM);

                //Update the progress dialog.
                String message = mContext.getResources().getString(R.string.downloading_artwork_for) + " "
                        + title;
                String[] progressParams = { message, "" + currentProgress };
                publishProgress(progressParams);

                //Remove any unacceptable characters.
                if (artist.contains("#")) {
                    artist = artist.replace("#", "");
                }

                if (artist.contains("$")) {
                    artist = artist.replace("$", "");
                }

                if (artist.contains("@")) {
                    artist = artist.replace("@", "");
                }

                if (album.contains("#")) {
                    album = album.replace("#", "");
                }

                if (album.contains("$")) {
                    album = album.replace("$", "");
                }

                if (album.contains("@")) {
                    album = album.replace("@", "");
                }

                //Replace any spaces in the artist and album fields with "%20".
                if (artist.contains(" ")) {
                    artist = artist.replace(" ", "%20");
                }

                if (album.contains(" ")) {
                    album = album.replace(" ", "%20");
                }

                //Construct the url for the HTTP request.
                URL url = null;
                try {
                    url = new URL(
                            "http://itunes.apple.com/search?term=" + artist + "+" + album + "&entity=album");
                } catch (MalformedURLException e1) {
                    // TODO Auto-generated catch block
                    continue;
                }

                String xml = null;
                try {

                    //Create a new HTTP connection.
                    HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();

                    urlConnection.connect();

                    //Check if albumArt.xml already exists and delete it.
                    if (xmlFile.exists()) {
                        xmlFile.delete();
                    }

                    //Create the OuputStream that will be used to store the downloaded data into the file.
                    FileOutputStream fileOutput = new FileOutputStream(xmlFile);

                    //Create the InputStream that will read the data from the HTTP connection.
                    InputStream inputStream = urlConnection.getInputStream();

                    //Total size of target file.
                    int totalSize = urlConnection.getContentLength();

                    //Temp variable that stores the number of downloaded bytes.
                    int downloadedSize = 0;

                    //Create a buffer to store the downloaded bytes.
                    buffer = new byte[1024];
                    int bufferLength = 0;

                    //Now read through the buffer and write the contents to the file.
                    while ((bufferLength = inputStream.read(buffer)) > 0) {
                        fileOutput.write(buffer, 0, bufferLength);
                        downloadedSize += bufferLength;

                    }

                    //Close the File Output Stream.
                    fileOutput.close();

                } catch (MalformedURLException e) {
                    //TODO Auto-generated method stub
                    continue;
                } catch (IOException e) {
                    // TODO Auto-generated method stub
                    continue;
                }

                //Load the XML file into a String variable for local use.
                String xmlAsString = null;
                try {
                    xmlAsString = FileUtils.readFileToString(xmlFile);
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

                //Extract the albumArt parameter from the XML file.
                artworkURL = StringUtils.substringBetween(xmlAsString, "\"artworkUrl100\":\"", "\",");

                if (artworkURL == null) {

                    //Check and see if a lower resolution image available.
                    artworkURL = StringUtils.substringBetween(xmlAsString, "\"artworkUrl60\":\"", "\",");

                    if (artworkURL == null) {
                        //Can't do anything about that here.
                    } else {
                        //Replace "100x100" with "600x600" to retrieve larger album art images.
                        artworkURL = artworkURL.replace("100x100", "600x600");
                    }

                } else {
                    //Replace "100x100" with "600x600" to retrieve larger album art images.
                    artworkURL = artworkURL.replace("100x100", "600x600");
                }

                //If no URL has been found, there's no point in continuing.
                if (artworkURL != null) {

                    artworkBitmap = null;
                    artworkBitmap = mApp.getImageLoader().loadImageSync(artworkURL);

                    File artworkFile = new File(Environment.getExternalStorageDirectory() + "/artwork.jpg");

                    //Save the artwork.
                    try {

                        FileOutputStream out = new FileOutputStream(artworkFile);
                        artworkBitmap.compress(Bitmap.CompressFormat.JPEG, 90, out);

                    } catch (Exception e) {
                        e.printStackTrace();
                    } finally {

                        Artwork artwork = null;
                        try {
                            artwork = ArtworkFactory.createArtworkFromFile(artworkFile);
                        } catch (IOException e) {
                            // TODO Auto-generated catch block
                            setArtworkAsFile(artworkFile, dataURIsList.get(i));
                            continue;
                        } catch (ArrayIndexOutOfBoundsException e) {
                            // TODO Auto-generated catch block
                            setArtworkAsFile(artworkFile, dataURIsList.get(i));
                            continue;
                        } catch (Exception e) {
                            e.printStackTrace();
                            setArtworkAsFile(artworkFile, dataURIsList.get(i));
                            continue;
                        } catch (Error e) {
                            e.printStackTrace();
                            setArtworkAsFile(artworkFile, dataURIsList.get(i));
                            continue;
                        }

                        if (artwork != null) {

                            try {
                                //Remove the current artwork field and recreate it.
                                tag.deleteArtworkField();
                                tag.addField(artwork);
                            } catch (Exception e) {
                                // TODO Auto-generated catch block
                                setArtworkAsFile(artworkFile, dataURIsList.get(i));
                                continue;
                            } catch (Error e) {
                                e.printStackTrace();
                                setArtworkAsFile(artworkFile, dataURIsList.get(i));
                                continue;
                            }

                            try {
                                audioFile.commit();
                            } catch (CannotWriteException e) {
                                // TODO Auto-generated catch block
                                setArtworkAsFile(artworkFile, dataURIsList.get(i));
                                continue;
                            } catch (Error e) {
                                e.printStackTrace();
                                setArtworkAsFile(artworkFile, dataURIsList.get(i));
                                continue;
                            }

                        }

                        //Delete the temporary files that we stored during the fetching process.
                        if (artworkFile.exists()) {
                            artworkFile.delete();
                        }

                        if (xmlFile.exists()) {
                            xmlFile.delete();
                        }

                        //Set the files to null to help clean up memory.
                        artworkBitmap = null;
                        audioFile = null;
                        tag = null;
                        xmlFile = null;
                        artworkFile = null;

                    }

                }

            }

        }

    }

    audioFile = null;
    file = null;
    //System.gc();

    return null;

}

From source file:com.google.ytd.SubmitActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.setContentView(R.layout.submit);

    this.authorizer = new GlsAuthorizer.GlsAuthorizerFactory().getAuthorizer(this,
            GlsAuthorizer.YOUTUBE_AUTH_TOKEN_TYPE);

    dbHelper = new DbHelper(this);
    dbHelper = dbHelper.open();/*from   ww w. ja v a2  s  .c  o m*/

    Intent intent = this.getIntent();
    this.videoUri = intent.getData();
    this.ytdDomain = intent.getExtras().getString(DbHelper.YTD_DOMAIN);
    this.assignmentId = intent.getExtras().getString(DbHelper.ASSIGNMENT_ID);
    this.title = intent.getExtras().getString(DbHelper.DESCRIPTION);
    this.instructions = intent.getExtras().getString(DbHelper.INSTRUCTIONS);

    this.domainHeader = (TextView) this.findViewById(R.id.domainHeader);
    domainHeader.setText(SettingActivity.getYtdDomains(this).get(this.ytdDomain));

    this.preferences = this.getSharedPreferences(MainActivity.SHARED_PREF_NAME, Activity.MODE_PRIVATE);
    this.youTubeName = preferences.getString(DbHelper.YT_ACCOUNT, null);

    final Button submitButton = (Button) findViewById(R.id.submitButton);
    submitButton.setEnabled(false);

    submitButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            showDialog(DIALOG_LEGAL);
        }
    });

    Button cancelButton = (Button) findViewById(R.id.cancelButton);
    cancelButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            setResult(RESULT_CANCELED);
            finish();
        }
    });

    EditText titleEdit = (EditText) findViewById(R.id.submitTitle);
    titleEdit.setText(title);
    titleEdit.setEnabled(false);
    enableSubmitIfReady();

    EditText descriptionEdit = (EditText) findViewById(R.id.submitDescription);
    descriptionEdit.setText(instructions);
    descriptionEdit.setEnabled(false);

    Cursor cursor = this.managedQuery(this.videoUri, null, null, null, null);

    if (cursor.getCount() == 0) {
        Log.d(LOG_TAG, "not a valid video uri");
        Toast.makeText(SubmitActivity.this, "not a valid video uri", Toast.LENGTH_LONG).show();
    } else {
        getVideoLocation();

        if (cursor.moveToFirst()) {

            long id = cursor.getLong(cursor.getColumnIndex(Video.VideoColumns._ID));
            this.dateTaken = new Date(cursor.getLong(cursor.getColumnIndex(Video.VideoColumns.DATE_TAKEN)));

            SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, MMM d, yyyy hh:mm aaa");
            Configuration userConfig = new Configuration();
            Settings.System.getConfiguration(getContentResolver(), userConfig);
            Calendar cal = Calendar.getInstance(userConfig.locale);
            TimeZone tz = cal.getTimeZone();

            dateFormat.setTimeZone(tz);

            TextView dateTakenView = (TextView) findViewById(R.id.dateCaptured);
            dateTakenView.setText("Date captured: " + dateFormat.format(dateTaken));

            ImageView thumbnail = (ImageView) findViewById(R.id.thumbnail);
            ContentResolver crThumb = getContentResolver();
            BitmapFactory.Options options = new BitmapFactory.Options();
            options.inSampleSize = 1;
            Bitmap curThumb = MediaStore.Video.Thumbnails.getThumbnail(crThumb, id,
                    MediaStore.Video.Thumbnails.MICRO_KIND, options);
            thumbnail.setImageBitmap(curThumb);
        }
    }
}

From source file:com.netcompss.ffmpeg4android_client.BaseVideo.java

private String[] getVideoPath(String name) {
    // TODO Auto-generated method stub
    Log.e(Tag, "file name:" + name);
    Uri mUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
    String[] cloumns = { MediaStore.Video.VideoColumns.DATA, MediaStore.Video.VideoColumns._ID,
            MediaStore.Video.VideoColumns.TITLE, MediaStore.Video.Thumbnails.DATA };
    String selection = MediaStore.Video.Media.DATA + " Like '%" + name + "'";
    Cursor videocursor = BaseVideo.this.cordova.getActivity().managedQuery(mUri, cloumns, selection, null,
            null);// w  ww  . j a  v  a 2  s . co m
    if (videocursor.getCount() > 0) {
        videocursor.moveToFirst();
        while (!videocursor.isAfterLast()) {
            String path = videocursor.getString(0);
            String thumbpath = videocursor.getString(3);
            Log.e(Tag, "path:" + path + "  thumb:" + thumbpath);
            String[] temp = path.split("/");
            if (temp[temp.length - 1].equalsIgnoreCase(name)) {
                Bitmap thumb = ThumbnailUtils.createVideoThumbnail(path,
                        MediaStore.Images.Thumbnails.MINI_KIND);
                FileOutputStream fos = null;
                String extr = Environment.getExternalStorageDirectory().toString();
                File mFolder = new File(extr + "/MYAPPBUILDER2");
                if (!mFolder.exists()) {
                    mFolder.mkdir();
                } else {
                    mFolder.delete();
                    mFolder.mkdir();
                }

                String s = "myappbuilder.png";

                video_thumbpath = new File(mFolder.getAbsolutePath(), s);
                // returnPath = video_thumbpath.getAbsolutePath();

                try {
                    fos = new FileOutputStream(video_thumbpath);
                    thumb.compress(Bitmap.CompressFormat.PNG, 100, fos);
                    fos.flush();
                    fos.close();
                } catch (FileNotFoundException e) {

                    e.printStackTrace();
                } catch (Exception e) {

                    e.printStackTrace();
                }
                return new String[] { "success", path };
            }
            videocursor.moveToNext();
        }

    } else {
        return new String[] { "error", "Video not Founded..." };
    }
    return new String[] { "error", "Video not Founded..." };
}

From source file:com.money.manager.ex.home.HomeFragment.java

private void renderAccountsList(Cursor cursor) {
    linearHome.setVisibility(cursor != null && cursor.getCount() > 0 ? View.VISIBLE : View.GONE);
    linearWelcome.setVisibility(linearHome.getVisibility() == View.GONE ? View.VISIBLE : View.GONE);

    mAccountsByType.clear();/*w  ww.  ja v a2  s  . c  om*/
    mTotalsByType.clear();
    mAccountTypes.clear();
    mGrandTotal = MoneyFactory.fromDouble(0);
    mGrandReconciled = MoneyFactory.fromDouble(0);

    // display individual accounts with balances
    if (cursor != null) {
        showAccountTotals(cursor);
    }

    // write accounts total
    addFooterToExpandableListView(mGrandTotal.toDouble(), mGrandReconciled.toDouble());

    // create adapter
    HomeAccountsExpandableAdapter expandableAdapter = new HomeAccountsExpandableAdapter(getActivity(),
            mAccountTypes, mAccountsByType, mTotalsByType, mHideReconciled);
    // set adapter and shown
    mExpandableListView.setAdapter(expandableAdapter);

    setVisibilityOfAccountGroups();
    setListViewAccountBillsVisible(true);
}

From source file:net.smart_json_database.JSONDatabase.java

private String getPropterty(SQLiteDatabase db, String key, String defaultValue) {
    String returnValue = defaultValue;

    Cursor c = db.rawQuery("SELECT * FROM " + TABLE_Meta + " WHERE key = ?", new String[] { key });

    if (c.getCount() > 0) {
        //int key_col = c.getColumnIndex("key");
        int value_col = c.getColumnIndex("value");

        c.moveToFirst();//from ww w  .jav  a  2s. co  m

        if (c != null) {
            if (c.isFirst()) {
                do {
                    returnValue = c.getString(value_col);
                    if (Util.IsNullOrEmpty(returnValue)) {
                        returnValue = defaultValue;
                    }
                    break;
                } while (c.moveToNext());
            }
        }
    }
    c.close();

    return returnValue;
}

From source file:com.spoiledmilk.ibikecph.util.DB.java

public int favoritesForName(String name) {
    int ret = 0;/*w  w w.j  av  a  2s  . co  m*/
    SQLiteDatabase db = getReadableDatabase();
    if (db != null) {
        String[] columns = { KEY_NAME };
        Cursor cursor = db.query(TABLE_FAVORITES, columns, KEY_NAME + " = ? ", new String[] { "" + name }, null,
                null, null, null);
        if (cursor != null && cursor.moveToFirst()) {
            ret = cursor.getCount();
        }
        if (cursor != null)
            cursor.close();
        db.close();
    }
    return ret;
}

From source file:com.gimranov.zandy.app.ItemActivity.java

/**
 * Called when the activity is first created.
 *//*from   w ww  .ja  v  a 2s. c om*/
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    String persistedSort = Persistence.read(SORT_CHOICE);
    if (persistedSort != null)
        sortBy = persistedSort;

    db = new Database(this);

    setContentView(R.layout.items);

    Intent intent = getIntent();
    collectionKey = intent.getStringExtra("com.gimranov.zandy.app.collectionKey");

    ItemCollection coll = ItemCollection.load(collectionKey, db);
    APIRequest req;

    if (coll != null) {
        req = APIRequest.fetchItems(coll, false, new ServerCredentials(this));
    } else {
        req = APIRequest.fetchItems(false, new ServerCredentials(this));
    }

    prepareAdapter();

    ItemAdapter adapter = (ItemAdapter) getListAdapter();
    Cursor cur = adapter.getCursor();

    if (intent.getBooleanExtra("com.gimranov.zandy.app.rerequest", false) || cur == null
            || cur.getCount() == 0) {

        if (!ServerCredentials.check(getBaseContext())) {
            Toast.makeText(getBaseContext(), getResources().getString(R.string.sync_log_in_first),
                    Toast.LENGTH_SHORT).show();
            return;
        }

        Toast.makeText(this, getResources().getString(R.string.collection_empty), Toast.LENGTH_SHORT).show();
        Log.d(TAG, "Running a request to populate missing items");
        ZoteroAPITask task = new ZoteroAPITask(this);
        req.setHandler(mEvent);
        task.execute(req);

    }

    ListView lv = getListView();
    lv.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            // If we have a click on an item, do something...
            ItemAdapter adapter = (ItemAdapter) parent.getAdapter();
            Cursor cur = adapter.getCursor();
            // Place the cursor at the selected item
            if (cur.moveToPosition(position)) {
                // and load an activity for the item
                Item item = Item.load(cur);

                Log.d(TAG, "Loading item data with key: " + item.getKey());
                // We create and issue a specified intent with the necessary data
                Intent i = new Intent(getBaseContext(), ItemDataActivity.class);
                i.putExtra("com.gimranov.zandy.app.itemKey", item.getKey());
                i.putExtra("com.gimranov.zandy.app.itemDbId", item.dbId);
                startActivity(i);
            } else {
                // failed to move cursor-- show a toast
                TextView tvTitle = (TextView) view.findViewById(R.id.item_title);
                Toast.makeText(getApplicationContext(),
                        getResources().getString(R.string.cant_open_item, tvTitle.getText()),
                        Toast.LENGTH_SHORT).show();
            }
        }
    });
}