How can Android application access a centralized database - android

I am working on an application which has large amount of data in a database. I know that it wont be feasible for me to package this huge database along with the app. I can only think of setting up a central database, so that the app can access it. I am new to android. I thought about using web-services or a http webpage request.
any suggestions for this?
thanks,
Naveen

Of course, be familiar with the topics outlined in the Data Storage Developer's Guide.
http://developer.android.com/guide/topics/data/data-storage.html

Related

Sharing same SQLite DB for two android apps

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.

Best Database design option for Android application with huge data

I am new to Android Application Development and a new member at stackoverflow. I am currently trying to design a recipe application. I have decided upon the features of the app and the scope it will cover. The scope is very vast for me in terms of covering all the recipes from all over the world. I am to deal with a lot of data in this process.
I am currently trying to figure a good and efficient way of handling the data in my app. So far, as per what I have read in different forums, I believe that I have two options in terms of a database choice : 1) SQLite 2) Database on remote server (MySql/Postgre)
Following are some of the thoughts that have been going on in my mind when it comes to taking a decision between the two :
1) SQLite : This could be a good option but would be slow as it would need to access the file system. I could eliminate the slowness by performing DB data fetch tasks in the AsyncTask. But then there could be a limitation of the storage on different phones. Also I believe using SQLite would be easier as compared to using a remote DB.
2) Remote Database : The issue that I can see here is the slowness with multiple DB requests coming at the same time. Can I use threads here in some way to queue multiple requests and handle them one by one ? Is there an efficient way to do this.
Also I have one more question in terms of the formatting of my data once I pull it out from the above DB's. Is there a way I could preserve the formatting of my data ?
I would be more than thankful if someone could share their knowledgeable and expert comments on the above scenario. Also this is not a homework for me and I am not looking for any ready made code solutions. I am just looking for hints/suggestions that would help me clear my thoughts and help me take a decision. I have been looking for this for sometime now but was not able to find concrete information. I hope I will get some good advice here from the experienced people who might have encountered similar situation.
Thanks for reading this long post.
What about combining both approaches?
A local SQLite database that has the least recently used receipes so you don't need network all the time. Network is way slower than accessing the filesystem.
Some remote database accessed via some HTTP interface where you can read / write the whole database. And if you want users to be able to add receipes for other users to see you'll need an external database anyways.
SQLite : This could be a good option but would be slow as it would need to access the file system.
Accessing a local database is pretty fast, 5ms or so if it's just a simple read only query on a small database.
But then there could be a limitation of the storage on different phones
Depends on your definition of huge database. It is okay if it is only 2MB which would be enough to store lots of text-only receipes.
Also I believe using SQLite would be easier as compared to using a remote DB.
Yes, Android has a nice built-in SQLite API but no remote database API. And you don't need to setup a database server & interface.
The issue that I can see here is the slowness with multiple DB requests coming at the same time.
A decent database server can handle thousands of requests. Depends on your server hardware & software. https://dba.stackexchange.com/ should have more info on that. Required performance depends on how much users you have / expect.
I'd suggest a simple REST interface to your database since it's pretty lightweight but does not expose your database directly to the web. There are tons of tutorials and books about creating such interfaces to databases. There are even hosted database services like nextDb that do most of the work for you.
Is there a way I could preserve the formatting of my data ?
You could store HTML formatted data in your database and display it in a WebView or a TextView (via Html#fromHtml()) - both can display formatted text.
Databases don't care what type of text you store, for transfer over the internets you may need to encode the text so it does not interfere with the transport formatting (XML, JSON, ...).
A simple way is to integrate Parse into your app. They have a nice framework that easily integrates into iOS and Android. Their plan is freemium, so you'll be able to use up to 1 million API request for no charge, and then its 7 cents for every request after that.
You'll have 1gb to store all your data sets / images, etc.
I don't use parse for everything, but I HIGHLY recommended it for large data schemes because they do all the scaling for you. Check out the API, I think it would be worth your time.
I just started to work on a few of my own projects, and I'm using Parse again. I have to say it's improved a lot over the last 6-8 months. Especially with the Twitter and Facebook integration.
The key issue here is the size of the data - any significant database of recipes would be too large to store on the phone imho,thus you seem stuck with the remote database solution.
As opposed to trying access the remote database from android I suggest you use a a go between web application that will process requests from the application and return JSON objects that you need.
It totally depends on your software requirements. If you need to deal with a small amount of data then you may choose SQLite, but for a huge amount to data better use a remote DB.
SQLite: It works fine with little amount of data & I experienced it response time is good.
Remote DB: I think you may use small server side app to submit the data to your client app. It will solve/reduce your thread related issues/complexities.

Is there a way to change the default SQLITE database location on an android phone, to a folder on an HPH website?

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.

Android sqlite database update?

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.

How i connect MySql in android

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

Categories

Resources