Android Sql Lite download from sql server using webservice - android

I have a website which display quotes grouped by author.
The front end is in asp.net and the database is in sql server 2012.
The table is simple with four fields.
Id numeric and primary key
Author nvarchar
Quote nvarchar
Insertdate datetime.
Now, I want to create a mobile app on both Android and ios platform.
First I started with Android using android studio.
I have the basic design ready with layout.
Now, I am stuck with the main requirements which is I want to give user the options of downloading the quotes when online and the quotes already downloaded should be available offline.
I have been trying multiple tutorial but can't find the one with the exact requirements.
So, is this the below right way of going forward?
I created a webservice and transferring the data using retrofit library. Now I'm able to display the data but not storing it locally. As this part is complete just want to be sure if I have done it the correct way as don't want to rollback once I start working on the part two that is storing the data in sqlite.
Also, can I reuse some of the functionality on ios.

Seems reasonable.
What you probably want to do now is introduce local storage for the data so they don't have to be online and accessing the API all the time. For Android SQLite is the normal way of storing data, and iOS uses Core Data (although SQLite is available).
Everything up to the API is reusable, you'll need to develop the download and storage for each ecosystem separately.
NB - that being said, I believe that Google's Firebase cloud database has an offline mode, so you could potentially work around the need to develop the syncs separately and use Firebase's SDK to get the data into an auto synced local store. Haven't used it myself, but it;s out there.

Related

Storing User's Game Progress

I'm working on a cross platform game which will support both logins and 'guest' play. The benefit to logging in is, of course, that your game progress will be saved and accessible via multiple devices. For guest play I'll just be storing game progress locally via JSON or something similar.
What do you see as the best way of saving game progress externally? When the user logs in, their completion should be fetched and updated locally, and when the user completes an action (beats a level, etc.) their completion should be updated locally and then pushed to the external source, too.
Initially I was considering just MySQL with a Levels table or something similar, but would a JSON approach (MongosDB, maybe?) be best? What would you recommend?
Thanks!
If you don't want to spend time learning a web language and database, you can use a Backend as a Service (BaaS) provider like Parse.com
If you do want to learn a web language and database, you can take your pick of anything, really. Your problem is simple and it'll make an effective learning exercise no matter what you choose.
CoreData. For both local and external use.
It has more than you asked for, but may be challenging to get into.
From what I see, also SQLite should do the job. I could say that is lighter than Core Data.
SQLite is a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine. SQLite is the most widely deployed SQL database engine in the world. The source code for SQLite is in the public domain.
SQLite

creating a database for a website and mobile app

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/

Android Dev SQL vs JSON

I'm writing an Android app that I want to use in conjunction with a band website I've developed. The website uses a SQL database to hold information such as blogs, band member information, tour dates, etc.
What data access method would make the most sense to use? I've looked at Andriod dev on tekpub and JSON data access is incredibly easy, however would it make sense to parse the database into JSON just for Android access?
Is there a good way to hit the SQL database as is? Any advice, tutorial links, or examples would be great.
It's a standard to use JSON or XML to transfer data from a server to an android client.
Giving direct access to the SQL from the devices would be a bad idea as it would
expose a large security hole
make your data base schema more difficult to change (too many clients would rely directly on its structure)
just not work in most cases as database driver are not meant to be used this way, they often use a stable channel to communicate with the database server.

which kind of database to use with android app?

I am developing an android program for my university. I am confused about which database to use.
What I want is that when the user is connected to the internet the program will check for any updates in the backend database. If there is any, the program will sync it with Android device.
Let's assume that after while the user opens the program in place with no internet, the program will work just fine because the file is already in his mobile.
I chose Access and created .xml file and by the help of this site: XML resources in android. I learnt how to read it.
Actually this program is my senior project. I dont want the judges to ask me why didn't I use MySQL or SQLite.
Which database system should I use? Is Access the right database system to choose?
I want to do a program that looks just like Univ of Kent program.
Parsing XML could take time, also in XML you have no choice but to load the whole file.
SQLite is fast, simple to use and very dynamic.
Android offers a very simple SQLite API. Androoid SQLite API
If you are interested in reading more about all the data storage types in Android visit this link
It depends upon your requirement. lets say you want to build something which handles and stores the data on your device locally then SQLite is a good option (you can use firebase as well).if you want to do some sort of calculation on you data on a remote server then firebase is a best choice .
by using firebase you can store your data generated by your users and then if you want you can carry out some analytics as well.
i would prefer Firebase .

Android Remote Database

I'm in the process of developing an Android application that will need to connect to a central database. Users should be able to access records and add records to the database through the application. The data itself will be fairly simple with each record being made up of a number of text fields.
The database will be developed specifically for the application and only needs to be accessed through the application. Initial reading seems to indicate that a web service should be written to parse data into xml format, for use by the app.
Seen as the database is being developed from scratch, specifically for this purpose, I would like to make sure I am heading in the right direction. I have very little experience with databases and would really just like a pointer on where to start reading. Any suggestions on the format the database should take would be greatly recieved too.
Thank you
You seem to have the idea down, if it were me, I would recomend using JSON instead of XML for the Webservice, they work in very similar ways, but JSON is a lot smaller and will make the application noticeably (as in it will make a diference for the user) faster. This is specially true if you are sending large amounts of data.
Take a look at this:
GSon
If your familiar with other aspects of Java, you could make the implementation entirely server side by means of JSPs. You could access the database via the phone's browser or any other browser. If you implemented a DAO factory on the server, this would enable you to switch databases from say Oracle, to MySQL etc by means of a properties file.

Categories

Resources