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

  • Home
  • SEARCH
  • 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 9235949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:10:24+00:00 2026-06-18T07:10:24+00:00

So I currently store a bunch of string titles together into a file on

  • 0

So I currently store a bunch of string titles together into a file on the user’s phone and then read it later (when they relaunch the app). I’m trying to read back the string and split it on the delimiter I set for it but for some reason it splits it and then doubles the string…

So for example if I stored these strings

Ricky(har)Bobby(har)is(har)cool(har)

(har) is the delimiter I use to store them. (for example)

For some reason, when I use the split function on “har”

It gives me an array of strings, but doubles how many I stored… So the array of strings would have two Ricky’s two Bobby’s two is’s and two cool’s.
I’m at a loss for what’s going on to be honest. Been staring at this for hours… anyone have any idea?

line = BR.readLine();
            String[] each = line.split("<TAG>");
            for (int i = 0; i < each.length; i++) {
                listOfCourses.add((each[i]));
                //Toast.makeText(context, each[i], Toast.LENGTH_SHORT).show();
            }

Here’s the function that stores the data to the user’s phone

//adds data into the classes file on user's phone
    public void addClassesIntoFile(Context context, ArrayList<String> classList) {
        try {
            FileOutputStream fos = context.openFileOutput(CLASSLIST_FILENAME,
                    Context.MODE_PRIVATE | Context.MODE_APPEND);
            OutputStreamWriter osw = new OutputStreamWriter(fos);
            for (int i = 0; i < classList.size(); i++) {
                osw.write(classList.get(i) + "<TAG>");
            }
            osw.flush();
            osw.close();
        } catch (FileNotFoundException e) {
            // catch errors opening file
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
  • 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-18T07:10:26+00:00Added an answer on June 18, 2026 at 7:10 am

    I don’t believe your split function is the problem and instead think it’s with some other part of your code.

    1. Is the String before you conduct the split correct? Or do you see duplications in it?
    2. I imagine the problem is with your addClassIntoFile method. Since you are appending into the File, be sure you aren’t re-adding values that are already there. Unless you delete that file at some point, it’ll persist the next time the app is launched.
    3. Finally make sure you aren’t calling addClassIntoFile more then you meant too. IE, accidentally invoking it more then once on a given object.

    If I’m incorrect on all this, then please post an example of what the String looks like before a split so we can be sure the given regex is correct.

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

Sidebar

Related Questions

Currently I store the user's FirstName and LastName in the USER table, but i
Currently, when I STORE into HDFS, it creates many part files. Is there any
Our application currently stores bunch of configuraton & application specific data to files on
I currently store a series of tweets as documents in mongodb the schema of
Is armv7 an absolute requirement for submission to the app store currently? The application
I'm currently trying to store images in a psql table and was following this
Currently the way I store strings is by using Localizable.strings, for example English: URL
I currently use SQL Server to store products in a large catalog web site.
I currently have an application in the play store for both tablets and smartphone
Using Core Data w/a sqlite store on iPhone.... I've got a bunch of comic

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.