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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:38:49+00:00 2026-06-10T05:38:49+00:00

My code have some sqlite operators. I execute a sql, it has 500 rows

  • 0

My code have some sqlite operators. I execute a sql, it has 500 rows. Executing and getting rows take quite low time, but when I call cursor.close() function, it takes 10 seconds.

How can I reduce this time consume ?

Cursor cursor = database.rawQuery(sql, null);
while(cursor.moveToNext()){
     String str1 = cursor.getString(0);
     String str2 = cursor.getString(1);
     System.out.println(str1+" and "+str2);
}
cursor.close();  // this line takes 13 seconds. but above code takes only 200 ms

code is something like this

  • 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-10T05:38:50+00:00Added an answer on June 10, 2026 at 5:38 am

    I have suggest you to use method startManagingCursor(Cursor c) of Activity Class. Lets Activity handle Cursor for you as per Activity Life Cycle..

    Form Docs StartManagingCursor…

    public void startManagingCursor (Cursor c)
    Since: API Level 1
    

    This method is deprecated.
    Use the new CursorLoader class with LoaderManager instead; this is also available on older platforms through the Android compatibility package.

    This method allows the activity to take care of managing the given Cursor’s lifecycle for you based on the activity’s lifecycle. That is, when the activity is stopped it will automatically call deactivate() on the given Cursor, and when it is later restarted it will call requery() for you. When the activity is destroyed, all managed Cursors will be closed automatically.

    If you are targeting HONEYCOMB or later, consider instead using LoaderManager instead, available via getLoaderManager().

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

Sidebar

Related Questions

I have some code that reads a datetime from a sqlite database, the datetime
I have some code that inserts a record into a SQLite table: $statement =
I have some django code that runs fine on a SQLite database or on
I'm a complete beginner with Code::Blocks and SQLite, and have some basic knowledge with
I have some code in Python that sets a char(80) value in an sqlite
I am using the sqlite v3, i have the table which has some columns
We have some ancient Delphi code (might have even originated as Turbo Pascal code)
I have a php page and i have some javascript code to have a
I have some code on two systems running kernel 2.4.20 and kernel 2.4.38 .
I have some code that will change the background color of a specific label

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.