Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8718271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:30:09+00:00 2026-06-13T06:30:09+00:00

I’m trying to fill an ArrayList with the owner’s emails. I’m doing this in

  • 0

I’m trying to fill an ArrayList with the owner’s emails. I’m doing this in a fragment. Here is my code :

 public class ItemDetailFragment extends Fragment implements
        LoaderManager.LoaderCallbacks<Cursor> {

    ArrayList<String> emails = new ArrayList<String>();

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        getLoaderManager().initLoader(0, null, this);

    }


        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
                View myFragmentView = inflater.inflate(R.layout.formal_email_layout,
                                container, false);
                return myFragmentView;
       }


 public Loader<Cursor> onCreateLoader(int id, Bundle arguments) {
            return new CursorLoader(getActivity(),
                    // Retrieve data rows for the device user's 'profile' contact.
                    Uri.withAppendedPath(
                            ContactsContract.Profile.CONTENT_URI,
                            ContactsContract.Contacts.Data.CONTENT_DIRECTORY),
                    ProfileQuery.PROJECTION,

                    // Select only email addresses.
                    ContactsContract.Contacts.Data.MIMETYPE + " = ?",
                    new String[]{ContactsContract.CommonDataKinds.Email.CONTENT_ITEM_TYPE},

                    // Show primary email addresses first. Note that there won't be
                    // a primary email address if the user hasn't specified one.
                    null);
        }

public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) {
            List<String> emails = new ArrayList<String>();
            cursor.moveToFirst();
            while (!cursor.isAfterLast()) {
                emails.add(cursor.getString(ProfileQuery.ADDRESS));
                // Potentially filter on ProfileQuery.IS_PRIMARY
                cursor.moveToNext();
            }

               Log.d("test", cursor.getString(ProfileQuery.ADDRESS));
            }


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

            private interface ProfileQuery {
                String[] PROJECTION = {
                        ContactsContract.CommonDataKinds.Email.ADDRESS,
                        ContactsContract.CommonDataKinds.Email.IS_PRIMARY,
                };

                int ADDRESS = 0;
                int IS_PRIMARY = 1;
            }

    }

I’ve basically used the example given here, I’ve just adapted it to a fragment.

When the fragment is lunched, the app crashes and I get this error :

07-05 12:27:55.235: W/dalvikvm(23217): threadid=1: thread exiting with uncaught exception (group=0x40c2f1f8)
07-05 12:27:55.235: E/AndroidRuntime(23217): FATAL EXCEPTION: main
07-05 12:27:55.235: E/AndroidRuntime(23217): android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0

(I do have one Gmail account on my device)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T06:30:10+00:00Added an answer on June 13, 2026 at 6:30 am

    Here’s a little class to get owner email.

    You can use only the first part of code where you get account name (google synchronization email address).

    • https://github.com/jehy/Android-GetOwnerInfo
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.