Opening An sqlite database in android - android

I have been trying to open my ready made sqlite data base
in my android application my question is:
how do I open an sqlite database with the function:
openOrCreateDatabase();
And where should i put the sqlite file
And if my approach is wrong please enlighten me

Best way to work with SQLLite on Android is having a class which extend SQLiteOpenHelper. Here is good end-end example on how to work with SQLLite on Android. http://www.screaming-penguin.com/node/7742

I would recommend using a SQLiteOpenHelper. You can extend it to create your own helper class.

Related

Using the same database in all activities Android SQLite

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?

Database inside of Android

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.

Using Existing sqlite Database with android ADT

I am developing an app in android which consists of activities that need to connect to the Database. I am having an existing sqlite DB with me. But I don't know how to include it in my project. This might be a very basic question, but as I am a newbie, I am finding it quite complex to get it working. Any help would be appreciated.
The easiest solution, by far, is to use SQLiteAssetHelper. You add one JAR to your project, package your database in a ZIP file in a specified location in your project's assets/ directory, then use SQLiteAssetHelper to access your database (much like you would use SQLiteOpenHelper).
try to read more about making a DatabaseHelper extension class
this really helped me during my first database driven app
http://www.codeproject.com/Articles/119293/Using-SQLite-Database-with-Android
The name of this feature of transfer database in android called database Ship.
I have already complete database shipUsing your own SQLite database in Android applications
Also you can see this Stackoverflow Answer

what is the best way to deal with SQLite database?

I am working on my graduation project
It has the same idea as calories counter application of Fatsecret >> if you know!
I created the database file using SQLite, I copied it into the asset folder, and then wrote the code as in this link:
http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/
recently I read a code that only use openOrCreateDatabase(name, mode, factory) to deal with the database
Can I use this in my case, which code is better?
Best Regards
There is good basic documentation on how to work with sqllite in android. Check out http://developer.android.com/guide/topics/data/data-storage.html#db to get an overview on how to use sqllite in your application.
Basic idea is to extend http://developer.android.com/reference/android/database/sqlite/SQLiteOpenHelper.html class and from there do the rest of CRUD operations on your database.
Also i forgot to mention: preferably avoid using openorcreatedatabase method, recommendation is to keep using sqliteopenhelper instead

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