Example usage for android.database Cursor getString

List of usage examples for android.database Cursor getString

Introduction

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

Prototype

String getString(int columnIndex);

Source Link

Document

Returns the value of the requested column as a String.

Usage

From source file:net.sf.sprockets.database.Cursors.java

/**
 * Get all String values in the first column.
 *
 * @param close true to close the cursor or false to leave it open
 *//*from ww w.  j  a v a  2 s  .co m*/
public static String[] allStrings(Cursor cursor, boolean close) {
    String[] s = EMPTY_STRING_ARRAY;
    if (cursor.moveToFirst()) {
        s = new String[cursor.getCount()];
        do {
            s[cursor.getPosition()] = cursor.getString(0);
        } while (cursor.moveToNext());
    }
    close(cursor, close);
    return s;
}

From source file:Main.java

public static ArrayList<ContentValues> getArea(SQLiteDatabase db, int dqx_dqxx01) {
    ArrayList<ContentValues> list = new ArrayList<ContentValues>();
    ContentValues values = null;//from www . j a v a2 s.c  om
    Cursor cursor = db.query(TABLE_NAME, new String[] { "DQXX01", "DQXX02", "DQXX05" }, "DQX_DQXX01=?",
            new String[] { "" + dqx_dqxx01 }, null, null, "DQXX01 ASC");
    if (cursor != null) {
        while (cursor.moveToNext()) {
            values = new ContentValues();
            values.put("area_id", cursor.getInt(0));
            values.put("area", cursor.getString(1));
            values.put("full_area", cursor.getString(2));
            list.add(values);
        }
    }
    if (cursor != null && !cursor.isClosed()) {
        cursor.close();
    }
    return list;
}

From source file:com.example.igorklimov.popularmoviesdemo.helpers.Utility.java

public static String getPoster(Cursor c) {
    return c.getString(c.getColumnIndex(MovieContract.COLUMN_POSTER));
}

From source file:com.example.igorklimov.popularmoviesdemo.helpers.Utility.java

public static String getGenres(Cursor c) {
    return c.getString(c.getColumnIndex(MovieContract.COLUMN_GENRES));
}

From source file:com.example.igorklimov.popularmoviesdemo.helpers.Utility.java

public static String getTitle(Cursor c) {
    return c.getString(c.getColumnIndex(MovieContract.COLUMN_TITLE));
}

From source file:com.example.igorklimov.popularmoviesdemo.helpers.Utility.java

public static String getReleaseDate(Cursor c) {
    return c.getString(c.getColumnIndex(MovieContract.COLUMN_RELEASE_DATE));
}

From source file:com.example.igorklimov.popularmoviesdemo.helpers.Utility.java

public static String getPlot(Cursor c) {
    return c.getString(c.getColumnIndex(MovieContract.COLUMN_PLOT));
}

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 w  w  w  . j  av  a  2  s . c  o  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.
 */
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()) {
            final int index = cursor.getColumnIndexOrThrow(column);
            return cursor.getString(index);
        }
    } finally {
        if (cursor != null)
            cursor.close();
    }
    return null;
}

From source file:Main.java

public static String getDataColumn(final Context context, final Uri uri, final String selection,
        final String[] selectionArgs) {
    Cursor cursor = null;
    final String column = "_data";
    final String[] projection = { column };

    try {/*w  ww.j  a v a2  s  .  com*/
        cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs, null);

        if (cursor != null && cursor.moveToFirst()) {
            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. // w  w  w.  j  a  v a  2 s . c o 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. 
 */
private 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()) {
            final int index = cursor.getColumnIndexOrThrow(column);
            return cursor.getString(index);
        }
    } finally {
        if (cursor != null)
            cursor.close();
    }
    return null;
}