i am new to android. i already created a database and store some data there. What i want is that the stored data in my database, I want to print it all out in another activity.
I don't know how to do this sharing of one database in all activities. I did research but they are all complex codes that i don't understand. Greatly appreciated if you could give me some simple codes about it. Thanks
im using SQLLite database.
You can use the same database throughout the whole app. In order to create an interaction bridge between your Activity and Database, you need to utilise few classes like ContentResolver and ContentProvider. Here is android example of how to create a ContentProvider -
Creating ContentProvider
You can also read this blog for better understanding about how things work in Android in terms of Database.
Hope it helps.
The same database can be used in all activities.You need to create a class through which you can access the database.Before I can tell you how to retrieve data you need to tell me somethings.You have written that you have already created a database.Have you created an external database and are trying use the database from assets folder or have you created an internal database in your android application?
Related
i,m making an android app which deals with counter information of bus train and plain in Bangladesh. I want to store those information into sqlite database. But i can't figure it out what will be the best approach to store those huge amount of info in a tabular form. I mean m i need to code all the data into my src file? OR is there any graphical UI (like MySql database) of this database to write the data into table without coding it?
i don't sure that you understand my question. If you not then please ask what point i make confusion. Advance thanks for helping :)
But i can't figure it out what will be the best approach to store those huge amount of info in a tabular form
SQLite
I mean m i need to code all the data into my src file?
Usually, you'd use an existing API to read the data you want from an existing database somewhere (in this case, often the transport department), and then programmatically iterate over it and store it locally
OR is there any graphical UI (like MySql database) of this database to write the data into table without coding it?
MySQL is not a graphical program. It is a database. You get various graphical interfaces for it, but on its own it isn't one.
MySQL doesn't work on Android
You can write a simple script or app easily enough to allow you to enter the data using a UI
I wonder whether there is a way to store data in like a MySQL inside of Android OS.
I have more complex data that I need to save and I dont think SharedPreferences will work.
Is there a predefined way, and how can I access it? Is it in SQL?
Of course there is. On Android each application has own place for database (SQLite). Read http://developer.android.com/reference/android/database/sqlite/SQLiteOpenHelper.html
for further details. It's really easy to maintain
Yep, there is SQLite
Here is a question asking for examples.
Here is the SQLiteDatabase class. Goo start point.
well there is SQLite database which is very light weight database to store data in android..
Edit
when you start working with SQLite on android you should not mix it up with MySQL or PHPMyAdmin or any other complex database structure. SQLite is just about storing some information on your device internally and accessing it for some purpose. It is not used for complex database tasks that you do in PhpMyAdmin.
Rather you should visit the links given by #Vee in the answer.
I would like to maintain single sqlite DB for two applications. I have seen other links and this was helpful Share SQLite database between 2 android apps?
But still when I declare the shared user ID and shared context, I could not achieve it.
In my first app- SQLite is created with few tables.
In my second app=- I would to create tables in the same DB which I created in first app
And also in few posts, I read that this can be achieved through remote Database.
Please can some one suggest me good tutorial where I can have some idea on how to proceed?
I would recommend what you've asked about - which is using a remote database.
Check out this: how to use free cloud database with android app?
Look into a hosted database in the cloud. Quite a few of them will let you get started for free. I know IrisCouch lets you get going for free and it's very easy. http://www.iriscouch.com/ The nice thing about CouchDB is you can do all your work via HTTP - which isn't too hard from an Android device.
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.
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