I'm new here, give me a solution about json please.
I want to fetch json data to my app from url, and also want to update json data regularly without url change.
suppose, i want to show trending products in an activity, after one day i will change some products of that activity by changing data from json. after updating my json, url cant be change, cause doing update whole app regularly for changing url is not a good idea.
so, is this possible to update json data without changing url?
if yes, tell me please where can i store my json so that i can update t regularly.
or if you can provide any other better possible way to do this, please help me.
Thank you.
That's why we use the database
Basically you need a database o structure your data, then you fetch data from the database using PHP which gives you a Json response
Since you are using Android Studio tag here is a good tutorial on how to fetch data from database using PHP , Json response tutorial
First you gonna start with LocalHost , consider using Xampp , Then use web hosting
You create your database using PhpMyAdmin in LocalHost/phpMyAdmin and you read the data using PHP which return it in Json Format
Then migrate to Web Hosting , in PhpMyAdmin you can export your Database from your LocalHost and Import it in your WebHost/PhpMyAdmin , and you upload your Php files also
Related
I want to fetch data from url, example from json.php and then store that to local sqlite in React Native. But I can't find any reference or any problem same like me
I tried to find another database to get data from url and store to local database, but it seems I can't find any case like me.
[{
"username":"****",
"password":"*****",
"access":"1",
"name":"dwi",
"phone_number":"****",
"email":"**#***.com",
"score":null,"status":"0"
},
{
"username":"*****",
"password":"****",
"access":"1",
"name":"******",
"phone_number":"**********",
"email":"******#**.com",
"score":null,
"status":"0"
}]
Here are the things you need to do -
1) Hit the url and retrieve the data [HTTP GET/ HTTP POST] depending on your api.
2) You need to parse the response.
Here is an example of using HTTP requests with react-native.
3) Now, after data is parse, you need to write it to your database.
Here is an example of handling SQLite with react-native.
Another example of sqlite here.
Now, please read the documentation and try to implement it.
As we all know parse server being shutdown, but if i want to use parse local data store concept without any parse server interaction(without calling parse initialize(context,appkey,masterkey)) , then how could we achieve this?
Please suggest me if we can use it or not? If not , any best option apart from parse server for local data store?
Thanks in adavance!
You can't use Parse local datastore without parse backend. Objects do not get an objectid until the device is in contact with the Parse backend. Parse pinning is meant as a convenience addition to the backend; not as a replacement.
If you're now considering using ONLY parse local datastore, you should replace your solution with Core Data instead. Or consider setting up your own Parse server at i.e. Heroku.
This question already has answers here:
How to sync SQLite database on Android phone with MySQL database on server?
(5 answers)
Closed 9 years ago.
I am building an Android app which will take some data and images from user and store them in a local SQLite DB. What I am looking for is a way by which I can replicate this DB to a MySQL DB on my server.
I looked on the Internet for the answer but there isn't a proper solution to it. Though the most common answers I found were SymmetricDB and setting up a web service. I am still confused which route to take.
The SQLite DB may also at need, have to pull updated data from the MYSQL DB, so I guess the better word to use is Sync rather than Replicate.
Yes of course, its Sync.
You have to create Web Service for that.
Just follow some steps for sending data from Android to MySQL:
Create JSON object of your data using JSONObject and JSONArray class.
post that as an string to your Web Service that might be in PHP or whatever you prefered.
process to parse json and insert data in to MySQL database.
Same as from MySQL to Android:
Create Web Service that displays your data in JSON Format.
then you have to Request to that link and you'll get JSON data, just you have to parse and store into SQLite.
You have to take care about Data Confiction. for that you have to take one that store some value both side like last sync date/time.
There are some tutorial that will help for android JSON Parsing and PHP JSON Parsing.
For Android
For PHP
If there is any problem then you can free to ping.
Happy Syncing.
Thank you.
I need some help, my app created a database on creation at the minute.
What I want is to get the information in a database on a server or PC and load it into my app.
It just needs to be from server to app, not back again.
I have no idea how I would do this, does anyone have any ideas?
first, I should say that your question is so wide. It contains alot of technologies.
So, I'll give you a breif walk through here. you should figure out the rest on your own. and then, you can come back and ask more specific questions.
That said, here is the path you should take:
On the server, implement a REST API that respond to the caller with the data in the server database.
example: http://your.server.com/api/somedata
calling this url with GET method should return the data you want in JSON format.
from your android application, call this url and save the response in a String.
parse the JSON String ( you can use gson ).
save the parsed data to your local database.
If you are the one developing the server api, then this book is a recommended reading:
RESTful Web Services
Update
Say you have a table in your server database called (TABLE) with the columns COL_1, COL_2, COL_3.
You could implement a php page called 'TABLE.php' that return the following:
{
"items": [
{"COL_1": "value_1", "COL_2": "value_2", "COL_3": "value_3"},
{"COL_1": "value_2", "COL_2": "value_3", "COL_3": "value_4"},
{"COL_1": "value_4", "COL_2": "value_5", "COL_3": "value_6"},
...
]
}
In your android application call http://your.server.com/api/TABLE.php page with GET method, parse the JSON returned (above) and save it to your local database.
You can do this for each database table on your server, until you have all your data saved locally in your android application.
This probably wont be the best design decision, but considering your knowledge about the topics, this could be a fair starting point.
Using HttpClient you can set things up to execute a POST to some servlet or similar app on the server. That app needs to then send data back to your Android app which is waiting for a response from the server. Then your app can parse the data and stuff it's own database.
I am creating an android application which records soccer scores.
I have an external mysql database created on my own host.
How do i retrieve the data from the database in order to display it in my application?
Thanks in advance!
You need to write a service hosted on your database using either php or some other language you are comfortable which exposes data as XML/JSON.
Android has HTTPURLConnection capability,using which you can query your service by passing the parameters. Your service queries database and consturcts data either as XML or JSON using libraries and returns to app.
Your app need to parse the response (if XML, using SAX/DOM or someother APIs, if JSON using Android in-buit json parser) and display. Here is an example on how to do.
If you also want to retrive the information to be used offline, you can create an empty database locally, and update it by passing SQL statements. This is not the most efficient way to do it, but it worked for me since I am not working with a huge db.
Otherwise, use HTTP connection connecting to your remote host and pass the result via JSON object.