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 7775565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:39:50+00:00 2026-06-01T17:39:50+00:00

Begginer android programer, I want add and remove item from String list when user

  • 0

Begginer android programer, I want add and remove item from String list when user click on listitem, but i get operation not supported error on trying to do that. See following code to understand what i want to do.

@Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
        super.onListItemClick(l, v, position, id);
        if(myList != null)
        {
            StringBuilder stringBuilder = new StringBuilder();
            if(myList.contains(mylist1.get(position).getPackageName()))
            {
                for(int i = 0; i < myList.size(); i++)
                {
                    if(myList.get(i).equals(mylist1.get(position).getPackageName()))
                        continue;
                    if((myList.size() - 1) != i)
                        stringBuilder.append(myList.get(i)).append(separator);
                    else
                        stringBuilder.append(myList.get(i));
                }
                editor.putString("mypreference", stringBuilder.toString());
                mylistt1.get(position).setDisabled(false);
       //error happens in following
                myList.remove(mylist1.get(position).getPackageName());
            }
      }
}

Here is the logcat

04-08 11:33:00.030: ERROR/AndroidRuntime(533): FATAL EXCEPTION: main
        java.lang.UnsupportedOperationException
        at java.util.AbstractList.remove(AbstractList.java:638)
        at java.util.AbstractList$SimpleListIterator.remove(AbstractList.java:75)
        at java.util.AbstractCollection.remove(AbstractCollection.java:229)
        at com.mypackage.myActivity.onListItemClick(myActivity.java:82)
        at android.app.ListActivity$2.onItemClick(ListActivity.java:319)
        at android.widget.AdapterView.performItemClick(AdapterView.java:292)
        at android.widget.AbsListView.performItemClick(AbsListView.java:1058)
        at android.widget.AbsListView$PerformClick.run(AbsListView.java:2514)
        at android.widget.AbsListView$1.run(AbsListView.java:3168)
        at android.os.Handler.handleCallback(Handler.java:605)
        at android.os.Handler.dispatchMessage(Handler.java:92)
        at android.os.Looper.loop(Looper.java:137)
        at android.app.ActivityThread.main(ActivityThread.java:4340)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:511)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
        at dalvik.system.NativeStart.main(Native Method)
  • 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-01T17:39:51+00:00Added an answer on June 1, 2026 at 5:39 pm

    If myList has a datatype of List, it is immutable. You cannot make changes to it. So you would get operation not supported exception. Change myList datatype to an ArrayList before trying to make the changes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am a begginer in android,here I have activity that use web service: SoapObject
i am begginer to jquery and have a simple problem.. I want to make
I m begginer in cocos2d I want to make simple game in cocos2d. I
I'm C++ begginer. I did this excercise from Deitel's book: Use a one-dimensional array
i have a basic function which requires serializing in my android app. The user
I´m a begginer on C Language and I need to copy pixels to Android
Begginer to Android development. I am developing a application, which have three different tabs.
I'am begginer in android programming and I'am trying to create app that is logging
Please, correct me, where i'm wrong (i'm a begginer) I want to store a
Begginer's question. I'm trying to write small piece of code in Visual Studio (VB.net)

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.