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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:47:41+00:00 2026-05-24T00:47:41+00:00

I have an app that uses an sqlite database. Currently I have a database

  • 0

I have an app that uses an sqlite database. Currently I have a database helper class that I call from within my main class to access the database. I then temporarily store the items I retrieved in a cursor. Every time I want to access my database I have to open the db, create a new cursor, query the db and add the results to the cursor, pull the information out of the cursor, close the cursor, close the db, then display to the user.

Now I’m accessing the db helper class every time I want to access the db
I’m creating a new cursor every time
And I’m making sqlite queries.

I was wondering if I should change my code to do something like:
Open DB
Store all data to a cursor
close db

then whenever I want to access the information I can instead just reference the cursor eliminating the need to call the db helper class again.

Or would it be more efficient to instead store the data to an array doing something like:
open db
store data to a cursor
loop through cursor and store data into an array
close cursor
close db

What would the difference be (processing time, and memory use) between these and is there an even more efficient way of doing this that uses the least resources? Is it faster to use an array or a cursor? I don’t want to waste cpu time calling unnecessary functions or use more memory storing bloated objects.

  • 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-05-24T00:47:42+00:00Added an answer on May 24, 2026 at 12:47 am

    In your activity if you want to execute a select query once and you using that data to your activity then you have to make a ArrayList or Hashmap from Cursor and then you have to close your cursor.

    But if you have to access a database many times and you are getting a different different results by executing a query then you have to use cursor and fetch data from cursor update to UI and close Cursor.

    You are using Helper class so it is the best choice so you don’t have to wonder about processing.

    when ever you want to fetch data then just make a object of Helper class,Open connection,execute query and return data,fetch data from cursor in your activity,Update UI,close database.

    this is the normal way and also it is a good way.

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

Sidebar

Related Questions

I have a simple app that uses an SQL Express 2005 database. When the
We have an app that uses simple one way binding with a GridView to
I have a Cocoa app that uses a WebView to display an HTML interface.
I have a rails app that uses heavily js (over 1MB total). I'd like
I have a Rails app that uses STI to handle different types of Users,
Context: I have a WPF App that uses certain unmanaged DLLs in the D:\WordAutomation\MyApp_Source\Executables\MyApp
I have an MFC sdi app that uses a splitter window to contain a
I have a plugin for an RCP app that uses BIRT. I have a
I have a .net interop project that uses an app.config file. When I am
I have a .net project (MySolution.Common) that uses the app.config. I am using the

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.