title: How to add list from cursor to intent in share button
body: <p>I have an app where I use content provider to work with DB. I have a list, which is inflated and shown to the user. I need to save that list into intent and send it with share button like what <a href="https://developer.android.com/training/sharing/send.html" rel="nofollow noreferrer">I found here</a></p>
  
  <p>Here are my questions-</p>
  
  <p>1) Do I need to convert cursor to list or do I need to create a second list and inflate it with cursor or is there any other variant?
  2) How can I customize the look of recieved message? </p>
  
  <p>Here is my code-</p>
  
  <pre><code>public class CatalogActivity extends AppCompatActivity implements LoaderManager.LoaderCallbacks&lt;Cursor&gt; {
  
      private static final String TAG = "myLogs";
  
      /** Identifier for the pet data loader */
      private static final int LIST_LOADER = 0;
  
      /** Adapter for the ListView */
      ListCursorAdapter mCursorAdapter;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_catalog);
  
          Log.v(TAG, "Зашли в catalog activity oncreate");
  
          // Setup FAB to open EditorActivity
          FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
          fab.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  Intent intent = new Intent(CatalogActivity.this, EditorActivity.class);
                  startActivity(intent);
              }
          });
  
          // Find the ListView which will be populated with the list data
          ListView listListView = (ListView) findViewById(R.id.list);
  
          // Find and set empty view on the ListView, so that it only shows when the list has 0 items.
          View emptyView = findViewById(R.id.empty_view);
          listListView.setEmptyView(emptyView);
  
          // Setup an Adapter to create a list item for each row of list data in the Cursor.
          // There is no items data yet (until the loader finishes) so pass in null for the Cursor.
          mCursorAdapter = new ListCursorAdapter(this, null);
          listListView.setAdapter(mCursorAdapter);
  
          // Setup the item click listener
          listListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
              @Override
              public void onItemClick(AdapterView&lt;?&gt; adapterView, View view, int position, long id) {
                  ShoppingListBdHelper helper = new ShoppingListBdHelper(view.getContext());
                  if (helper.setCompleted(id)) {
                      mCursorAdapter.setCompleted(view);
                  }
              }
          });
  
          // Kick off the loader
          getSupportLoaderManager().initLoader(LIST_LOADER, null, this);
      }
  
      /**
       * Helper method to insert hardcoded item data into the database. For debugging purposes only.
       */
      private void insertPet() {
  
          Log.v(TAG, "Создали insertpet");
  
          Intent myIntent = new Intent(Intent.ACTION_SEND);
  
          String shareBody = "Body here";
          String shareSub = "Sub here";
          myIntent.putExtra(Intent.EXTRA_TEXT, shareSub);
          myIntent.putExtra(Intent.EXTRA_TEXT, shareBody);
          myIntent.setType("text/plain");
          startActivity(Intent.createChooser(myIntent, "Share using"));
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu options from the res/menu/menu_catalog.xml file.
          // This adds menu items to the app bar.
          getMenuInflater().inflate(R.menu.menu_catalog, menu);
          return true;
      }
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          // User clicked on a menu option in the app bar overflow menu
          switch (item.getItemId()) {
              // Respond to a click on the "Insert dummy data" menu option
              case R.id.action_insert_dummy_data:
                  insertPet();
                  return true;
              // Respond to a click on the "Delete all entries" menu option
              case R.id.action_delete_all_entries:
                  deleteAllItems();
                  return true;
              case R.id.menu_item_share:
                  shareIntent();
                  return true;
          }
          return super.onOptionsItemSelected(item);
      }
      /**
       * Helper method to delete all list in the database.
       */
      private void deleteAllItems() {
  
          Log.v(TAG, "Сработал метод удаления всех данных");
          long rowsDeleted = getContentResolver().delete(ListContract.ListEntry.CONTENT_URI, null, null);
          Log.v("CatalogActivity", rowsDeleted + " rows deleted from list database");
      }
  
      private void shareIntent(){
          ArrayList&lt;String&gt; list = new ArrayList&lt;String&gt;();
  
          Intent sendIntent = new Intent();
          sendIntent.setAction(Intent.ACTION_SEND);
          sendIntent.putStringArrayListExtra("test", (ArrayList&lt;String&gt;) list);
          sendIntent.setType("text/plain");
          startActivity(sendIntent);
      }
  
      @Override
      public Loader&lt;Cursor&gt; onCreateLoader(int i, Bundle bundle) {
          Log.v(TAG, "Начал работать loader cursor");
          // Define a projection that specifies the columns from the table we care about.
          String[] projection = {
                  ListContract.ListEntry._ID,
                  ListContract.ListEntry.COLUMN_ITEM_NAME,
                  ListContract.ListEntry.COLUMN_ITEM_DESCRIPTION,
                  ListContract.ListEntry.COLUMN_ITEM_COMPLETED
          };
  
          // This loader will execute the ContentProvider's query method on a background thread
          return new CursorLoader(this,   // Parent activity context
                  ListContract.ListEntry.CONTENT_URI,   // Provider content URI to query
                  projection,             // Columns to include in the resulting Cursor
                  null,                   // No selection clause
                  null,                   // No selection arguments
                  null);                  // Default sort order
  
      }
  
      @Override
      public void onLoadFinished(Loader&lt;Cursor&gt; loader, Cursor data) {
          // Update {@link ListCursorAdapter} with this new cursor containing updated pet data
          mCursorAdapter.swapCursor(data);
          Log.v(TAG, "Cursor adapter загрузился");
      }
  
      @Override
      public void onLoaderReset(Loader&lt;Cursor&gt; loader) {
          // Callback called when the data needs to be deleted
          mCursorAdapter.swapCursor(null);
      }
  }
  </code></pre>