Making a database helper class for a table with many fields - android

I'm currently trying to learn how to use a SQLite database with android. I've managed to successfully follow http://www.androidhive.info/2011/11/android-sqlite-database-tutorial/ but I'm now looking to make a table with 25-30 fields. It seems like it would be a huge task to type out all this in a similar style to that link especially as I'd want to be able to search by many of those fields.
Is there something I can use to automatically generate a database helper class with this number of fields and methods to search them? Or am I going about this completely the wrong way?
Thanks

First off i just recently started android programming also and i particularly enjoyed this tutorial about databases : http://www.vogella.de/articles/AndroidSQLite/article.html
To generate the queries i think it will be better you use an SQLite Database Manager and just copy and past your queries in the methods.

Related

How do I transfer a database from SQLiteStudio to an Android phone?

I have created a database in SQLiteStudio. The database consists of a single table, with columns 'Name', 'Age' and 'Occupation', and several rows of data.
I want to transfer that database from SQLiteStudio to an Android phone. How would I do this?
Well, the simplest way if there are only a few rows would probably be to create the schema and populate it in SQLiteOpenHelper.onCreate(db) using SQL statements executed with db.execSQL().
If you would like to avoid that however, and just directly take the database that you've created externally over into your app, you could look into Android SQLiteAssetHelper
Yes, the Android SQLiteAssetHelper is really simple compared to other guides that uses hundred of lines with codes. Tried numerous guide and tutorials before I found out about that helper. Here is a really simple guide to follow where he's using it and explains it pretty good.
Import and use external database in Android

Making a database with android?

I'm working on an android project that requires writing to a created database and later reading from it.
The idea is for the user to fill out a form and then submit, it will submit into a database table in the first row. Then if they hit submit again it will submit to the second row.
I have all of the activity layouts defined but I'm confused on how to make the databases. I'm thinking maybe I can make a content provider?
Can anyone advise me on what to do? All of the questions I look at on here skip the baby steps, and that's what I need
Yes you should make a content provider. There are a lot of great tutorials out there for making databases - try section 8.0 of this one
http://www.vogella.com/articles/AndroidSQLite/article.html
Since you plan to use a pre-loaded (created) database wherein the DB structure has been already defined, Refer to this link on how to include your pre-created DB file into your app :
http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/
And to then add new data to your database refer to this tut.. You can ignore the create Table part here since you already have the table structure ready.
http://www.androidhive.info/2011/11/android-sqlite-database-tutorial/
Hope this helps.
First of all you dont need Content provider...Content provider is only need when you want to provide your data to other application...Its kind of central repository of data for other applications.
Now You have to use the SQLITE database in android...Since android support sqlite database..
Below link will guide you...
http://developer.android.com/training/basics/data-storage/databases.html
Google has large manuals for all the aspects of Android development http://developer.android.com/training/basics/data-storage/databases.html
it might be done without content providers too.
this might be helpful.
http://www.androidhive.info/2011/11/android-sqlite-database-tutorial/

How can i use Sqlite database in my android activity?

I am creating a sample application using sqlite database unfortunately I am not familiar in sqlite database concepts. I have the following requirements,
I have a sqlite database named as quotes.db. The database having two fields in is number and Quotes. Which is stored in assets folder.
In my Activity i have two fields one is edittext and another one is button.
When the user enter the value (number) in edittext and click the button. Now I display the corresponding quotes which is stored in database.
if any one having sample code snippet similar to this kindly post. Thanks in advance.
You can follow this tutorial which is an introduction to Android apps and especially to databases in Android.
Quting the website:
This tutorial on writing a notepad application gives you a "hands-on"
introduction to the Android framework and the tools you use to build
applications on it. Starting from a preconfigured project file, it
guides you through the process of developing a simple notepad
application and provides concrete examples of how to set up the
project, develop the application logic and user interface, and then
compile and run the application.
There are a couple of ways of creating and accessing a database in android.
Method 1: Use simple SQL statements
For that follow this tutorial: http://saigeethamn.blogspot.in/2009/10/android-developer-tutorial-part-12.html
Method 2: Use a class that extends SQLiteOpenHelper
For that follow this tutorial: http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/
I would recommend you to follow method 2 as that makes it much simpler to query and update your database once it is all set up. Also note that when you move on to 'Content Providers' method 2 will again be very very helpful.
The Android dev manual has a useful introduction to the process. Take a look at the Searchable Dictionary for some example code.
I gave an answer on this SO question for importing a database from a file in your assets/ directory.

Alternative to using relationship with SQLite

I'm creating an app which is going to have some data that is stored in an SQLite database. I want the user to be able to create "folders" which can be assigned to each data item.
I was going to do this using a one to many relationship e.g. one "folder" can have many data objects under it but having looked at relationships with SQLite and Android it seems that this would only work in 2.2+ so I'm just wondering what the alternative is?
Any information is much appreciated.
You can still have relationships; older versions of SQLite just won't enforce them. As a stopgap, you can build triggers to do it; in fact there's a handy generator that will generate the SQL for you to use as a starting point.

What kind of database is used in Android document call functions?

Okay, so I am still learning to do some coding here, and I seem to have gotten stuck.
I want to have a select number of documents added to a package for the Android OS
but I don't know how to store said documents. Do I add them all under res/raw, or make an SQLite database and call from there?
More importantly, I need to be able to call those documents when a search criteria is added.
I was on the Android reference site, and they add write functions for the SQLite db, which I would prefer not having as an option.
What kind of database should I implement here?
I would prefer a link to an example, but anything would help at this point.
Try reading this.
Notepad example
or make an SQLlite database and call from there?
No you don't create a SQLlite database it will be created for you after your App start the database call.
See this SQLiteOpenHelper
And SQLiteDatabase

Categories

Resources