Sqlite for Android - android

I m developing an app similar to uber with android as front-end with rest api to serve data which is stored in mysql.
I would like to know if sqlite is used instead of mysql to achieve the above process because of the reasons sqlite exist in phone and data 'll be deleted after uninstalling the app.

sqlite database in android is used to store data which will not be stored in the backend but inside your phone only which you would not like to fetch from network everytime! for instance- user's ride history or user specific data. Although they'll need to be updated in regular interval.
In mysql you would need to store the backend data. so these two are two different things.
i hope you understand the diff among these and if you don't you should read a lot about these.

Related

What is the best way to store app data and load it in app?

This is just a information question. I'm new to Android app development and currently I'm working on my first app and and it is ready for the release. Now I'm concerned about how to handle heap of users and where to save all their details my app is a service booking app so it needs to save all the order details products details and lots other stuff.
Currently I'm using cloud firestore to load and save all the data of app. But I'm having some issues like without authentication it won't allow users to access some of my data and other. I wonder how large apps save their data and load them perfectly.
I wish someone will help me how can I save all my app data and load them perfectly in app. And suggest me for a best way to manage large user base. And other stuff.
First of all, firestore is good option if you don't have complex backend logic on the database. For simple CRUD operations on data firestore is a good choice but as you said you have a bulk of data then you must go for the Backend database and then connect your database with Rest API. So that all your complex queries will be done on the backend and you can simply consume your API in the app.
If you have lots of data from different users, maybe you should use a central server(DB), something like Postgres or MySQL should work fine.
At the same time, you can also do some sort of caching to accelerate the fetching process, like create a small database locally(you can use Room) to store some user specific data.

How to make changes to sqlite database for app that is installed in multiple devices?

I started developing an app that uses sqlite that is to be installed on multiple devices and any updates done on sqlite database from any device are to be reflected in other devices as well. I have researched a little and found that Sqlite DB is local to a device and changes done in one device are not reflected in others and for that I have to use external server. Is there any way around it?
Is it optimal to directly store data in external server or use sqlite and sync it regularly with external database?
Thanks in advance
As far as I know, there isn't a way without an external database. I would recommend you to sync it regularly with an external database.
Checkout this question for more information how to do that:
How to sync SQLite database on Android phone with MySQL database on server?
Answer of Andrew White
Create a webservice (REST is probably best) and serialize your SQLite/MySQL data and PUT/POST/GET it to/from your web service. This will give you a nice layer of abstraction in case you decide to switch from MySQL to something else server side.
You will achieve your goal using external server. It's not necessary to create your own server, just use data store services like Parse. For more look here.
You can use data directly from external server or cache them on your device first (sqlite, prefs, json etc.) – it's up to you.

How to store the content for android application

I'm a complete newbie in android development with some basic programming knowledge. Right now, I want to develop an E-Commerce app which allows the user to upload pictures for the public to browse through. However, I have no idea how should I store all the data, including the details(username and password) of the user, in the server. As far as I know, the database most often used in android is SQLite, but I'm not sure whether it's suitable to be used in my case.
Please shed some light. Any form of help would be much appreciated. Thanks in advance.
You could set-up a backend using some database (eg. MySQL) and some programming language (eg. PHP) as well as some kind of web-server (eg. Apache).
You would store the products,user data in tables of the database. Pictures would be stored on some directory on your server and you could store references to their path in the respective fields.
Your client (android) would load the products list as well as submit new products via issuing requests to your server back end, and perhaps store them in some SQLite database if you need the old items viewed to remain viewable without an internet connection.
A few tutorials to get you started:
http://www.androidhive.info/2012/05/how-to-connect-android-with-php-mysql/
http://www.tutorialspoint.com/android/android_php_mysql.htm
If you'll create an e-commerce mobile app, it cannot exists as a mobile app alone because it needs to connect to other users. You need to integrate it to a web service or a cloud service to tasks such as getting the item data, images, and other tasks involved. There are Baas (cloud) that you can use such as Parse and Kinvey.

Storing and fetching data in database

What I need the app to do is to store data in a database and let any user fetch the data. I am not sure how SQLite works but from what I know is that it is server-less. With the database being serverless, how do multiple users, other users, access the same data if it is not stored on a server?
look for backend and a service - parse.com or similar.
SQLite is installed on all android systems, and any app which wishes to create and use a database may do so. This however, is only stored locally on the device.
If you wish to share and synchronize data across multiple devices, that is a different issue all to itself. Indeed it will very likely involve a central server somewhere along the line.
Perhaps start your reading at d.android.com

approach for synching android app database with server db?

I'm developing an Android app as a "proof of concept" for our company. If they like it and think it's worth investing, then we'll move on to bigger things. I'm trying to figure out the best/most practical approach for this.....the basics of the app will connect to our DB and display information regarding a specific customer. For now, let's say we will only pull data from 3-4 tables (but there could be 10+ in the future). If the app doesn't have an internet connection then it should use the local DB. What is the best approach for this? Here's what I was thinking and would like some input/suggestions if possible:
1.) app runs checks internet connection. If exists, check db version (how, through a web service?)..if server db is newer, get latest data. If no internet, use local db.
2.) app parses data and displays it.
If this is correct, then there could be no modifications to the web service that would add fields to a result without changing the app as well. Is there a way for an app to parse fields regardless of how many fields there are?
I've read and walked through the tutorial on google with databases and such (Notepad tutorial) but it seems like the column names are all hard-coded in the parsing class, which I was hoping to avoid.
Sorry if this is confusing but I know I need my app to use a local db to read data, I also know that the app must get data from the server when it can (via onCreate or a refresh button) and copy it locally....Copying it locally is the part I'm having trouble understanding I guess....is there no way of saying "go out and get this result and display it", knowing that those results could mean 5 fields the first time or 1 the next.
Any help/guidance is greatly appreciated!
You probably want to use a SQLLite DB to store your data locally, a ContentProvider to provide CRUD access to the db, and a SyncAdapter to sync with your server when possible. The Sync Adapter also writes to the DB via the ContentProvider. See the SampleSyncAdapter sample in the SDK for an example of how this works. You will be implementing your own ContentProvider, but the sample just uses Android's supplied Contacts ContentProvider.
http://developer.android.com/resources/samples/SampleSyncAdapter/index.html

Categories

Resources