I'm new to MySQL database and past week I was trying to understand sending and receiving data from android app to MySQL database. what I'm confused about and tried to find it by google or stackOverFlow or even youtube is that what is the best way to save android app user setting (like leveling up feature for specific user)to MySQL database. I can do it easily by shared preference if I had plan to do it locally but I need to save it to online database, so can I save SharedPreferences to MySQL?. what is the best way ?
If you need to store data online either use a given service or build your own API by implementing a backend you can then communicate with e.g. by https://github.com/square/retrofit with https://github.com/square/okhttp. You could have an API call which you just pass your SharedPreferences as JSON data and store it in a MySQL text type. But of course building your own API for just storing some preferences might be too much effort.
Related
I am trying to make a tutorial app with the help of Android, but I am confused where I should put the whole content (topic details). Actually I want to use it with the help of SQLite database. I used hashmap in my app.
if you really want to store your data on app, then SQL is best option. Otherwise you can use Remote server to store data. and SQLite for offline access to already viewed data.
I'm not professional in android and i'm developing app which i want it to work in offline mode and online mode
my server is mysql and contain data i want in offline mode user can see data which is synchronized when app was online
after long search i found coughbase
but i don't know if it can help me or not
someone suggest me to use sqlite but i know sqlite can't save big data
i want to do this in fast way can anyone guide me what i should do ? and if examples is exists it will be good .. sorry for bad English
you can use preferences, when the app is online synchronize your data via web services (json) and save the on the user's phone or tablet via preferences, you can store what ever you like, it's not like a data base, you can store objects in a way it's like cookies on the browser.
your data will be saved as xml and accessed as objects and every class you wanna synchronize must implement Serializable interface.
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.
I want to be able to store multiple List<NameValuePairs> for when multiple users enter information into my Android application using the same device. Later on, the user should then be able to send their data to the server at a click of a button. But this should only be for later upload for example when there is wifi/network connectivity.
What is the best way to go about storing these List<NameValuePairs>?
Well, your best bet is to store the data in Android's SQLite database:
http://developer.android.com/guide/topics/data/data-storage.html#db
As an alternative you can just serialize your objects to a file, but that might be too much of a hussle if the data is big.
Then you can have a service that runs in the background and sends data from the local db to the server when possible.
Here are your storage options:
http://developer.android.com/guide/topics/data/data-storage.html
I would imagine that depending on the kind of data and size, SharedPreferences or SqlLite could be useful for you. You can back DB with a ContentResolver and implement sync (SyncService) to upload to server. In this case, the Android OS will intelligently sync your data on the cloud when network is reachable.
Decided to save everything as a long string of name value pairs seperated by ampersands for easy upload to database when sending to php server.
Actually i want to know how to store data from my app in the device so that i can review the store data when i run the application again..
means in simple terms i want to say that suppose i have text box where i write some information..now when i click the submit button, this information will be save,so that when i open the application the stored data should be appear in the text box..
In all terms i want to say that i just want to stored data in the way that we are using database for storing data..so please anyone suggest me how that can be done in android.
if possible show with an example
Regards
Anshuman
If you have to store small amount of data, you can use SharedPreferences in Android.
If the data that you have to store is big/complex enough, try using SQLite database.
Still need help?
UPDATE: There's a tutorial that I wrote to demonstrate how to use SQLite database. check it out here. Although it copies existing database into device's memory, but other versions of it, which create database through code can also be devised from it.
A better tutorial is here : http://www.vogella.com/tutorials/AndroidSQLite/article.html
1) If you want to store data in table format then you can use SQLite database in android
2) If you don't want to store data in table format then you can store in SharedPreference
more info about SharedPreference here and here
Android comes with a built in SQLite database that you can use. I advice you to go trough this notepad tutorial. It teaches the basics of using Android SDK including different states of the android application as well as how to use SQLite with Android.
For storing simple key = value pairs, you can use Properties.
For data storage as in a database, you can use sqlite on android.
Android provides several options for you to save persistent application data. The solution you choose depends on your specific needs, such as whether the data should be private to your application or accessible to other applications (and the user) and how much space your data requires.
Your data storage options are the following:
Shared Preferences
Store private primitive data in key-value pairs.
Internal Storage
Store private data on the device memory.
External Storage
Store public data on the shared external storage.
SQLite Databases
Store structured data in a private database.
Network Connection
Store data on the web with your own network server.
Data Storage