Returning all rows of a column from my content provider

I'm trying to access a Content Provider I already made (which I made by very closely following a tutorial, I've tested it with the code the tutorial walked me through and it works fine) and read the email addresses that I've added into a SQLite database. In the database is the ID, a COLUMN_NAME, and a COLUMN_EMAIL. I want to get all the rows for the email column and have that be an ArrayList of strings that's returned into this activity.

So far my best guess is that somewhere somehow I'll query the database using the query method from the content provider, return the cursor to the activity, and then collect all the Strings from the rows and either manage to send a query with a projection for just that column or filter out all the's or second index of the cursor or some kind of post data retrieval filter.

Basically I'm just pretty stuck.

Okay so here's my code:

public class EmailScheduler extends AppCompatActivity implements LoaderManager .LoaderCallbacks {

protected void onCreate(Bundle savedInstanceState) {
    Toolbar toolbar = (Toolbar) findViewById(;
    final TextView emailText = (TextView) findViewById(;
    FloatingActionButton fab = (FloatingActionButton) findViewById(;
    fab.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            Cursor cursor = getContacts();
            Log.i("TAG", cursor.getColumnName(2));

private static final int CONTACT_LOADER = 0;
public Uri contactUri;
ArrayList<String> addresses = new ArrayList<>();
Cursor cursor;

private Cursor getContacts() {
    // Run query
    Uri uri = Contact.CONTENT_URI;
    String[] projection = new String[] { Contact._ID,
            Contact.COLUMN_NAME };
    String selection = Contact.COLUMN_EMAIL + " = '"
            + ("1") + "'";
    String[] selectionArgs = null;
    String sortOrder = Contact.COLUMN_NAME
            + " COLLATE LOCALIZED ASC";
    return getContentResolver().query(uri, projection, selection, selectionArgs,
// called by LoaderManager to create a Loader
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    CursorLoader cursorLoader;

    switch (id) {
        case CONTACT_LOADER:
            cursorLoader = new CursorLoader(this,
                    contactUri, // Uri of contact to display
                    null, // null projection returns all columns
                    null, // null selection returns all rows
                    null, // no selection arguments
                    null); // sort order
            cursorLoader = null;

    return cursorLoader;

public void onLoadFinished(Loader<Cursor> loader, Cursor data) {

    Log.i("TAG", "got to the beginning of onloadfinish " + data);
    if (data != null && data.moveToFirst()) {
        int nameIndex = data.getColumnIndex(Contact.COLUMN_NAME);
        int emailIndex = data.getColumnIndex(Contact.COLUMN_EMAIL);
        String address = data.getString(emailIndex);
        Log.i("TAG", address);

        while (data.getString(emailIndex) != null){
            Log.i("TAG", addresses.toString());}

public void onLoaderReset(Loader<Cursor> loader) { }


In the onCreate method it returns this data when I run it: android.content.ContentResolver$CursorWrapperInner@60c9bd2

How do I get the information I need from that? Everything I try turns into a dead end.


private void getContacts() {
    List<String> addresses = new ArrayList<String>();    

    // Run query

    Uri uri = Contact.CONTENT_URI;
    String[] projection = new String[] { Contact.COLUMN_EMAIL };
    String selection = null;
    String[] selectionArgs = null;
    String sortOrder = Contact.COLUMN_EMAIL
            + " COLLATE LOCALIZED ASC";
    Cursor cursor = getContentResolver().query(uri, projection, selection, selectionArgs,
    TextView emailText = (TextView) findViewById(;
    if (cursor != null) {
        String category;
        for (int i = 0; i < cursor.getCount(); i++){
            category = cursor.getString(cursor
        // always close the cursor

Need Your Help

Customized Table CSS for a Single Table

html css css3

I wanted to know if there a way to customer a single table without effecting all other tables on the page or site. I found this CSS which I like a lot but its calling the table tag along with other...

Using std::vector<T*>::push_back with std::mem_fun and std::bind1st

c++ templates stl mem-fun

I'm trying to use std::vector&lt;T*&gt;::push_back with std::mem_fun and std::binder1st, but it doesnt seem to be feasible, can this be done?