I am trying to connect mysql in android, but I can't. Are there any alternate ways to developed application without mysql if there is small database needed. And which one is better to use mysql or sqlite and why?
You basically give the answer yourself: android has Sqlite built in, so if you need a DB in your app, you have to use SQLite.
The good thing is that it is small (and built in), so that it won't use much of the (limited) memory present on a mobile device.
You build a rest web service and then use http:// to push to that from your droid.
If you have to use the database in a scenario where your data comes from the Internet, then you would be using MySQL (or anything similar, like MSSQL) and will be developing web-services in PHP, or JSP or anything like that, to make your database available to your app.
If you have to use the database locally, you use SQLite
depends on the scenario.
For SQLite, refer this
Related
I'm starting to build a new Android application which will help me to manage material movements in a warehouse. I would like to use use a database for the following applications:
A table that will be managed from a server (my PC probably) to add or delete new users.
Also, there must be another table that will be managed by users. This table will be used to add or delete materials from the warehouse.
I'm not sure what kind of database to use. I have some knowledge of using MySQL Workbench to create and manage databases. However, I've read the SQLite is better for Android applications. Can you please help me to choose which one will be the best for my application?
Thanks
If the databases run on the android device (which I guess they do not from the description) SQLite is probably the way to go. I like this tutorial but there are millions out there.
If they run somewhere ales (server) you can choose whatever system you are comfortable with since you will have to implement some protocol to communicate between mobile device and server anyway (most people would use HTTP/REST for that, but again, you can do that in a million ways)
SQLite is indeed better for Android applications.
In terms of preloading tables, schemas, and data into a Sqlite database, you can use the SQLiteManager firefox extension to do it.
Or, if you're too lazy to care about what types of database to use, might as well use ORMLite for Android to manage your tables and schemas within your Android application.
As for your server, you'll need to expose the API so that you can do HTTP/RESTful operations on it. You can choose whatever web applications that you prefer.
I want to create a database so both my website and mobile app could draw info from there.
I know how to execute queries with a website, but I have little to none experience with mobile applications.
I heard I can't just use any form of database(mysql, mongodb) because they are not compatible or something.
so how do I create my database so it will be compatible with android iOS and PC.
A few guidelines to get me started would be great :)
Sounds like you need to build an API to handle interaction between your mobile applications and your database, in much the same way your website communicates with your database. The primary difference will be that you will be returning JSON/XML to your apps, rather than displaying HTML to a user.
I thoroughly recommend JSON over XML as it is not as verbose and data usage will drop dramatically. However, if you're data structures are quite detailed / complex, go with XML.
To get started with building an API I'll recommend Slim PHP. You'll probably want some form of ORM also, for which I highly recommend idiorm/paris
The documentation for both of these frameworks is great, so have a dig around.
You can create a database with MySQL and draw info from your site with mysql queries. As for your mobile app, you can use some php pages and JSON Parser to draw data from the database. See example
As you say android doesn't support external databases such as MySQL. The easiest thing to do would be to create a MySQL Database that your website and android app can access.
The website would access the MySQL database as normal but the android app instead posts data such as variables to a PHP script, the PHP script can then get the retrieved data and perform the mysql queryies and json_encode the output and print the encoded data. The android app would then receive the outputted json format and the android app can then decode the json and process the data accordingly.
http://www.helloandroid.com/tutorials/connecting-mysql-database has some tutorials on how this can be done
You need to use Service - Oriented Architecture.
You may use REST API methodology for creating interfaces.
See this example
www.hassanpur.com/blog/2010/09/android-development-implementing-a-simple-client-server-model/
I have an app that stores a sqlite database in the usual place. ie: data/data/com.blah.blah/databases. I wish to remotely locate the SQLITE database and read from and write to it. I wonder if there is a way to do it without using the Oracle Mysql option. Is there a way to just change the default location to a folder on a website. Thanks in advance. If so how do I do it. I cant find any tuts or books that explain how its done.
SQLite isn't a remote database implementation. That is kind-of part-of white it is called SQ*Lite*. :) It is for doing SQL databases based on local files, without taking the big additional overhead of having some remoteable service protocol sitting between you and the database.
There are all kinds of options for interacting with remote data stores, not just MySQL - PostgreSQL, etc. You can use whatever of those you want. You can then have on the device just the client code you need to communicate with the remote data store. It doesn't make sense for Android to supply any complicated/sophisticated here built-in, though, since exactly what you want is going to depend mostly on what you are using on your back-end server.
I am programming an app that will store a database locally and would like it to be able to update the database from a remote online database when changes have been made. I do not need to be able to write back to the remote database from the app. I am also trying to keep porting to IOS an option. How do i do this? thanks
This is a very general question, so the best I can do is give you a general answer. You can do this quite easily. Just use an HttpUrlConnection on your android app to pull data from the server and then update your database on the phone with the data you got from the server. If you want to get really fancy you can use a SyncAdapter, but that might be overkill for you needs.
When using a database for an Android application, is it possible to use a MySQL database, or do you have to use SQLite?
What I'm trying to do is make an app that allows users to see events on a map. These events are updated by admin staff from the office from a Java-based application that works with the MySQL database.
SqLite is present on the phone with some good tutorials out there to get you started using it.
Check the online docs for more details, and I suggest taking a look at the notepad sample, it will get you up to speed in no time.
http://developer.android.com/guide/topics/data/data-storage.html#db
As far as I know you have to use sqlite. MySQL needs a server which would mean you'd need a locally hosted mysql server on a phone which is going a bit overboard.
you have to use sqlite for your android side database
The best is to use content providers if you want to share information. Android provides built in interface for sqlite (android.database.sqlite) and so sqlite is easiest to use.
Another alternative to Sqlite is Berkeley DB for Android (Berkeley DB - Java Edition)