Android SQLite Best Practice Advice - android

This might be a bit cheeky but I would like some advice. I'm new to Android and have started to create my first app. I'm coming to the section where I need to create an SQLite DB with multiple tables and have been looking for best practices but have been unable to find my answer, this helped a little but not a lot What are the best practices for SQLite on Android?. I need about 6 tables in total.
Should I use one "constants" class to keep all of my table names, field names and database name in?
Should I create one "DBHelper" class to run all my SQL SELECT, UPDATE, DELETE in or create one per table?
Any other advice around best practices around maintaining the data or any other classes I need?
Bonus question :) If any one has any good examples they could point me towards as the Android documentation example is not in depth enough.
It's appreciated, I'm thinking about creating a blog with some simple examples for newbies to use as some of what I have read is a bit complex for small brains like mine.

I found this which answers what I'm looking for. Not sure how I didn't find this before with all the searching! Thanks for all your help guys/girls!
Multiple Table SQLite DB Adapter(s) in Android?

Related

Store website data in android device(SQLite,Realm or else)?

I am creating an android application, which i have load URL in to webView.
What exactly i want
I want to store website data which entered by users and store it in to Database.
The answer to this is it depends on your requirements. All have their benefits and trade offs around speed of different operations and simplicity.
I suggest you do some reading before making a choice. An article like this one will be a good start.
https://notes.devlabs.bg/realm-objectbox-or-room-which-one-is-for-you-3a552234fd6e
Personally I've been using Realm for over 2 years and it is fast for stuff like querying, however there are some technical caveats so make sure you read the documentation before you commit to it. I'm saying this because I didn't read it all, and although I don't regret using Realm, there is certainly some things that would have been useful to know before committing to it.
If Realm does interest you take a look at this documentation.
https://realm.io/docs/java/latest/

How to add more pages to android app?

I am a bit confused as I am new to android development. Let me put a scenario:
My app has 2 activities
SQL Lite DB related
List view
How should I use Android studio to combine both of the above? I cannot find a conclusive answer on the internet so that's why I am asking all the professionals out there.
Are you looking to have both in one page? In that case I would consider using Fragments, in which multiple to could housed into one activity and can run there. Could you elaborate more on what you are trying to do?
If you want to connect a ListView to some SQL database, there are many ways you can display that, but it depends on how the database is laid out.

Subclass Parse database class

In setting up the server aspect of my app that uses Parse, I realized that it would be very helpful if I could make subclasses on the actual database. Parse has a lot of information on subclassing, but this is on reference to creating a code subclass in the app to allow for code completion and debugging in the IDE. However I am looking for something else. I think it would be best explained through an example.
I have a _User class and I would like to create a Player, Team and Coach class that all inherit the columns of the _User superclass. This would save me form creating and maintaining all of these identical columns. This is exactly what subclassing means in normal programming, and I was wondering if it would be possible to do so on Parse, and if so, how would I do it? Thanks.
Update:
I recently found this question on the archived section of Parse questions which describes what I am looking to do, and furthermore gives it a technical name: "single table inheritance." However the question and response do not go into detail on how to actually implement this. Again, any help would be appreciated.
In reviewing the link attached to the question, I found out that
Relational databases don't support inheritance
so when trying to accomplish this, it cannot be done though the database (i.e. it cannot be achieved through Parse) so it needs to be mimicked on the client side.

work with database in android?

I wish to use database for my application.How to use the database in android.I use eclipse ide.Is there any requirements need for create database.Give some basic ideas about it.I am android beginner.Help me to know about it.
Since this question is worded almost exactly like how to use database in android? I would say you created a duplicate question. if not, see that question. If you need more, supply the info you would like to the initial answerers.
I think you should see Notepad sample project. There are a lot of common android practices there including database stuff.

How to insert rows/info into Android SQL DB with EditText and Buttons?

im working on a simple Android app, it is much like any other simple Database app. I have 4 EditText fields where the user inputs 4 different small pieces of text. I want this text to be inserted in to my Database table in the corrects rows for my columns. I am not really sure how to go about doing this. I know onClickListener needs to be used but not sure how to use it.
What you are looking for is the glue to make it work, as you have a storage ( your database ) and the user interface. But, as you pointed out just right, your onClick actions, or more widely spoken, your whole user-interaction needs to be filled with action.
I won't give you a specific advice here as I think you should read a bit about the Model-View-Controller Pattern here, as well as about how Android handles all that stuff. A good entrypoint for gaining knowledge is, as always, Wikipedia.
Don't get me wrong, I don't mean to offend you by not answering the specific question: I just think it's more valuable for you to first learn the basics required for building great apps instead of reading a step-by-step manual!
On my phone right now, but you are correct about setting up an onClick method for, let's just say, a Submit button.
I would look at the Developers Guide on the SQLiteDatabase on ways to insert values by executing a SQL statement or check into using ContentValues to insert values when the button's pressed, both could help you out.
Also, with a fair share of knowledge on databases the Developer Guide should be all you need, but if you need further help search for related questions.
NOTE
A good practice is getting used to debugging your code using LogCat. It helps when things go astray, especially when working with databases.
Tne Notepad Tutorial in the Android Developer Documentation takes you through creating an application which stores data from fields in an SQLite database.
You could work through this, or if you didn't want to do that it would be a good source of sample code.

Categories

Resources