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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:00:49+00:00 2026-05-31T15:00:49+00:00

I have subclassed SQLiteOpenHelper and have all the components of the code ready to

  • 0

I have subclassed SQLiteOpenHelper and have all the components of the code ready to use. The question is is that is it really good design to allow any activity to have direct access to public methods in the main database class.

I have a situation where my activity is going to populate information in its layouts based on what information it obtains from the database – essentially being dynamically created at runtime. since i am going to have multiple rows coming back from the database that means that i am going to have an array of whatever i need to get all the information.

So something like this:

 //in Main Activity Class
 private class menuItems{

    String category_name;
    int category_id;
    int menuItem_id;
    String menu_title;
    String menu_desc;
    String price;
    int icon;
}

  //ArrayList in Main Activity
   ArrayList<menuItems> menu = new ArrayList<menuItems>();

My activity needs this “struct” as its own – so that it can receive the information from the database – something like getAllMenuItems(), – where this method would perform a select statement, put together information is its own “struct” and return it back to the main activity. Then use this information within the activity to build the layouts/views, etc.

If i were to end up having a mediator class to talk to the database then that class as well would need the same “struct” defined in it. Would it be better design to have something like:

MainActivity

DatabaseAccessor – calls public DatabaseHelper classes(per request from MainActivity)

DatabaseHelper(subclasses SQLIteOPenHelper, performs all database queries)

I would like to design something along the lines of MVC(Model-View-Controller) but i was wondering what you guys thought of the practicality of this in an android application.

thanks!

  • 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-31T15:00:50+00:00Added an answer on May 31, 2026 at 3:00 pm

    In general, it’s a good idea to make the Activity and the database as decoupled from each other as possible. This allows you to be able to change the data-source by creating a class to access it, with no need to change the code that you use to present the data.

    So, yes, I would absolutely have a separate class for accessing the data, and a separate class to allow passing the data to the activity. I would also follow the Law of Demeter in this case, and provide any functionality needed to access or change the underlying data, without actually providing access to the underlying database.

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

Sidebar

Related Questions

so I have subclassed a UIViewController that I create. The question is, is there
In our iOS app, we have subclassed a UISlider in order to use a
Currenly in my cellForRowAtIndexPath function i have subclassed two UILabels that holds the values
I have subclassed the RadioButtonList control in order to create a Control Adapter that
I have a subclassed UIView (currentMapView) that draws a map of several states using
I have a subclassed NSManagedObject that conforms to the MKAnnotation protocol and it has
I'm writing a program that uses the Qt Graphics View framework. I have subclassed
I have got this code that I used before, but now that it I
I have subclassed UIView and created a NIB that controls the main logic for
I have subclassed a graphics control that takes a device context handle, HDC, as

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.