Skip to main content

Ready to market your stellar app?

Samsung Developer Program is your gateway to app monetization success.

Learn More

Samsung Developer Program

Getting and Caching a Purchased Items List

Available starting with IAP 3.0 Helper, you can optionally get a purchased items list and have it cached on the client. Subsequent loading of a client‑cached purchased items list is faster after the initial loading because client caching is supported. Additionally, this method gets a purchased items list for only the specified product item IDs.

To create an example using this method, add the files that were used in a previous section to the, inbox_list_layout.xml, and inbox_row.xml.

To get and cache a list of specified items purchased by the user:

    <!-- Cached InboxList Button -->
        android:onClick="doGetCachedInBoxList" />
private static final String ITEM_IDS = " Nuclear, Claymore, " +
                                       " Blockbuster";
    public void doGetCachedInBoxList( View _view )
        Intent intent = new Intent( MainActivity.this,
                                    CachedInboxListActivity.class );
        intent.putExtra( "IapMode", MODE );
        intent.putExtra( "ItemIds", ITEM_IDS );       

        startActivity( intent );
public class CachedInboxListActivity extends Activity
                                      implements OnGetInboxListener
    private int                mIapMode          = 1;
    private String             mItemIds          = "";   

    private SamsungIapHelper   mIapHelper        = null;

       private ListView           mInboxListView    = null;
    private TextView           mNoDataTextView   = null;
    private ArrayList<InboxVo> mInboxList        = new
    private InboxListAdapter   mInboxListAdapter = null;

    protected void onCreate( Bundle savedInstanceState )
        super.onCreate( savedInstanceState );       
        setContentView( R.layout.inbox_list_layout );       


        Intent intent = getIntent();

               if( intent != null && intent.getExtras() != null
                && intent.getExtras().containsKey( "IapMode" )
                && intent.getExtras().containsKey( "ItemIds" ) )
            Bundle extras = intent.getExtras();

            mIapMode = extras.getInt( "IapMode" );
            mItemIds = extras.getString( "ItemIds" );
            Toast.makeText( this,
                            Toast.LENGTH_LONG ).show();

        mIapHelper = SamsungIapHelper.getInstance( this, mIapMode );
        mIapHelper.getItemInboxList( mItemIds, this );

    public void initView()
        mInboxListView = (ListView)findViewById( );
        mNoDataTextView = (TextView)findViewById( );
        mNoDataTextView.setVisibility( View.GONE );       

        mInboxListView.setEmptyView( mNoDataTextView );

               mInboxListAdapter = new InboxListAdapter( this,
                                                  mInboxList );       

        mInboxListView.setAdapter( mInboxListAdapter );

    public void onGetItemInbox
        ErrorVo             _errorVo,
        ArrayList<InboxVo>  _inboxList
        if( _errorVo != null
                && _errorVo.getErrorCode() ==
                                        SamsungIapHelper.IAP_ERROR_NONE )
            if( _inboxList != null && _inboxList.size() > 0 )
                mInboxList.addAll( _inboxList );

The code above is almost identical to the previous section, EXCEPT that the getItemInboxList parameters are different in the highlighted area.

CAUTIONgetItemInboxList returns a list of ALL purchased items regardless of development mode.

​            android:name=".CachedInboxListActivity"
            android:label="@string/cached_items_inbox_list" >
  1. Add a button to run CachedInboxListActivity beneath the Purchase One Item button in the activity_main.xml layout, and set it to call the doGetCachedInboxList method when clicked.
  2. Specify new items in
  3. Set the required information in the intent and run CachedInboxListActivity by implementing the doGetCachedInboxList method as shown below in
  4. Add the following code to create a CachedInboxListActivity class. 
  5. Add CachedInboxListActivity to AndroidManifest.xml.

To test the cached purchased items list code:

  1. On a test device in Android Studio 1.1.0, run the purchasing code.
  2. Verify that a purchased items list similar to below is displayed.
  • Was this article helpful?