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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:51:04+00:00 2026-06-17T23:51:04+00:00

I’m not sure i’m using the efficient way to manipulate large number of strings.

  • 0

I’m not sure i’m using the efficient way to manipulate large number of strings.
I need to open a large file (~35kb) and parse and manipulate every line, ex:

a1="Name surname"
a2="Name surname"
a3="Name surname"
...
a800="Name surname"

I need to insert into a sqlite db every Name surname with the current id as index.

while ((s = d.readLine()) != null){
                        String[] name = s.split("\"");

                        String[] arrIdTemp = s.split("=");
                        String[] arrtId = arrIdTemp[0].split("a");

                        db.execSQL("INSERT INTO " + Constant.DB.DB_NAME
                                + " Values ('" + arrtId[1] + "','" + name[1]
                                + "');");

                    }

In this way i create 3 string arrays and for the first 100 lines is quite fast, but at the end the whole operation is slowing down, maybe because of a large use of memory? Is there a better solution to split and manipulate every line?

Logcat output says lots of:

01-27 14:46:50.554: D/dalvikvm(2541): GC_CONCURRENT freed 1778K, 68% free 3606K/11079K, external 4662K/5822K, paused 4ms+7ms
  • 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-17T23:51:06+00:00Added an answer on June 17, 2026 at 11:51 pm

    [1° SOLUTION]

    I split the two operations and use transactions. From about 60 seconds, now i need only 2-3 seconds.

    This is what i did:

    //List of query
    ArrayList<String> queryList = new ArrayList<String>();
    ...
    while ((s = d.readLine()) != null){
                            String[] name = s.split("\"");
    
                            String[] arrIdTemp = s.split("=");
                            String[] arrtId = arrIdTemp[0].split("a");
    
                            queryList.add("INSERT INTO " + Constant.DB.DB_NAME
                                    + " Values ('" + arrtId[1] + "','" + name[1]
                                    + "');");
    
                        }
    
    ...
    
    if (queryList!=null && queryList.size()>0){
                    Iterator<String> iter = queryList.iterator();
                    db.beginTransaction();
                    try {
                        while (iter.hasNext()) {
                             db.execSQL(iter.next());
                            }
                        db.setTransactionSuccessful();
                    } finally {
                        db.endTransaction();
                    }
                }
    

    if ther’s a better solution or improvements on what i did, please tell me.

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

Sidebar

Related Questions

I need a function that will clean a strings' special characters. I do NOT
I am using JSon response to parse title,date content and thumbnail images and place
In my XML file chapters tag has more chapter tag.i need to display chapters
I am using the SimpleRSS gem to parse a WordPress RSS feed. The only
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm not entirely sure how I managed to jack this up. http://pretty-senshi.com If you
I have thousands of HTML files to process using Groovy/Java and I need to
i want to parse a xhtml file and display in UITableView. what is the
I am using jsonparser to parse data and images obtained from json response. When
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

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.