Example usage for android.database DatabaseUtils dumpCursor

List of usage examples for android.database DatabaseUtils dumpCursor

Introduction

In this page you can find the example usage for android.database DatabaseUtils dumpCursor.

Prototype

public static void dumpCursor(Cursor cursor) 

Source Link

Document

Prints the contents of a Cursor to System.out.

Usage

From source file:Main.java

/**
 * Get the value of the data column for this Uri. This is useful for
 * MediaStore Uris, and other file-based ContentProviders.
 *
 * @param context The context.//from  ww  w  .  j av a2  s.  co  m
 * @param uri The Uri to query.
 * @param selection (Optional) Filter used in the query.
 * @param selectionArgs (Optional) Selection arguments used in the query.
 * @return The value of the _data column, which is typically a file path.
 * @author paulburke
 */
public static String getDataColumn(Context context, Uri uri, String selection, String[] selectionArgs) {

    Cursor cursor = null;
    final String column = "_data";
    final String[] projection = { column };

    try {
        cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs, null);
        if (cursor != null && cursor.moveToFirst()) {
            if (DEBUG)
                DatabaseUtils.dumpCursor(cursor);

            final int column_index = cursor.getColumnIndexOrThrow(column);
            return cursor.getString(column_index);
        }
    } finally {
        if (cursor != null)
            cursor.close();
    }
    return null;
}

From source file:Main.java

/**
 * Get the value of the data column for this Uri. This is useful for
 * MediaStore Uris, and other file-based ContentProviders.
 *
 * @param context       The context.//from   www  .j a  v a  2 s.  co m
 * @param uri           The Uri to query.
 * @param selection     (Optional) Filter used in the query.
 * @param selectionArgs (Optional) Selection arguments used in the query.
 * @return The value of the _data column, which is typically a file path.
 * @author paulburke
 */
public static String getDataColumn(Context context, Uri uri, String selection, String[] selectionArgs) {

    Cursor cursor = null;
    final String column = "_data";
    final String[] projection = { column };

    try {
        cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs, null);
        if (cursor != null && cursor.moveToFirst()) {
            if (DEBUG)
                DatabaseUtils.dumpCursor(cursor);

            final int column_index = cursor.getColumnIndexOrThrow(column);
            return cursor.getString(column_index);
        }
    } catch (IllegalArgumentException ex) {
        Log.i(TAG, "getDataColumn: _data", ex);
    } finally {
        if (cursor != null)
            cursor.close();
    }
    return null;
}

From source file:com.example.droidcodin.popularmdb.MovieDetailFragment.java

@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    // if (data.getCount() > 0 ){
    mDetailCursor = data;/*from w w  w  . ja va 2  s  .c o m*/
    mDetailCursor.moveToFirst();
    DatabaseUtils.dumpCursor(data);

    mMovieID = mDetailCursor.getString(ProjectionConstant.COL_MOVIE_ID);

    // get the movie title from DB
    mMovieTitle = mDetailCursor.getString(ProjectionConstant.COL_MOVIE_TITLE);

    mTitleTextView.setText(mDetailCursor.getString(ProjectionConstant.COL_MOVIE_TITLE));
    imageURL = mDetailCursor.getString(ProjectionConstant.COL_MOVIE_POSTERPATH);

    Picasso.with(this.getActivity()).load("http://image.tmdb.org/t/p/w185/" + imageURL).into(mImageview);

    mOverview.setText(mDetailCursor.getString(ProjectionConstant.COL_MOVIE_OVERVIEW));
    mReleaseDate.setText(mDetailCursor.getString(ProjectionConstant.COL_MOVIE_RELEASEDATE).substring(0, 4));
    mRating.setText(mDetailCursor.getString(ProjectionConstant.COL_MOVIE_VOTEAVG));

    checkFavourites(mMovieID);

    fetchMovieVideos();

    fetchMovieReviews(mMovieID);

    mMovieStr = mMovieTitle + "\n" + youTubeBaseURL + mFirstVideoStr;

    // If onCreateOptionsMenu has already happened, we need to update the share intent now.
    if (mShareActionProvider != null) {
        mShareActionProvider.setShareIntent(createMovieShareIntent());
    }

}