Upload RecyclerView To Php Server Android - php

I am developing E-Store App I want to upload the cart data which i am getting from php server to recycler view. I want to upload the whole recycler view to the database using Retrofit 2.0 and rest API.i want to know how to do it or there is another method to do it better

You can use Room from Android Architecture Components (Jetpack) for storing data in local database.
Some Info: https://developer.android.com/training/data-storage/room/index.html
Release notes: https://developer.android.com/jetpack/androidx/releases/room

Related

File upload using the API's

I had developed a website for my client and now the mobile team is developing the android app for them. For that, I created some API to get the data which will be initiated by the android developers.
Now, I need to upload the file(video or document) using the APIs. Link to my database and file to my specific folder.
Example API which I used to get the product details
http://xxxxxxxx.com/xxxxxx/api/doctor_pitch_details?email=mahesh#gmail.com&password=123456789&product=22
can anyone help me how to do it.
Don't use get use multipart and tell your android team to send data in multipart form so you can get a file at your end get file like
$user_photo = $_FILES['faile_param_name']['name'];

linking android application to the mysql database phone and link the info as well

Hey guys im faced with a challenge of linking my localhost mysql/php when adding something in a form that form should also be linked with my android application.
ex. I have made a form for the admin whereby they could add a new bus route and it will be stored into their database using php mysql in localhost server now that new route should also be linked to my android application it should display the new route (My android application uses sqlite database so two different database here) so when users use the application when they search for new route it should also display as well
How can i go with that? any ideas please im really stuck in this
thank you
Well there are generally 2 approaches to follow when you want to 'Sync' your web database to your mobile database
Push Notifications: You could send a push notification to all your users, whenever a new route is added to the mysql db. When the notification is received by your app, (it's not necessary you show the notification to the user) you could just ping the server for the new route, or you can send the 'route' in the message part of the push notification if you can, and then add this new route to your sqlite database.
AccountManager: Using the AccountManager is the preferred method when you want to Sync your data. The AccountManager uses the SyncAdapter to Sync your apps data with it's cloud. When Android pings the servers of other apps for syncing, it pings your app's server too, and syncs your data. This method also takes care of issues like, if the internet connection was not working when it was intended to sync, so android will schedule the next sync soon.
To provide a good service, you should take a look at a client-agnostic API architecture.
In this architecture, you have a PHP/go/whatever-written API, that can or can not be REST (but it's reccomended), that will provide, given a HTTP petition, the desired result.
Using PHP in the simplest way, you should create different .php files, one for each action ( www.myserver.com/getRoutes.php, www.myserver.com/getRouteDetail?routeId=3), and make those PHP files query the MYSQL database and return (echo) XML / JSON / Raw text.
this should then be parsed by your mobile application, and added/updated to your SQLite database.

How to retrieve link to an image from CakePHP to Android?

I'm fairly new with CakePHP and images so bear with me. You can assume I'm using the latest version.
I'm trying to build an Android application which can display images retrieved from the server.
Suppose I have an image in the assets folder called football.jpg. How would I store this in the database and then how would I output this to the Android application? Do I send only the link or do I send the whole image over? If it is just the link, does this mean I would have to reconnect to the server with the link and then get the image? Sorry if this doesn't make sense. Still trying to get my head around it.
Just a word of caution, it's probably better to store the file on the server's file system and store the path to the file in the database. The reason behind this is that BLOBs are stored in a different area on the file system to all your other typical data and in terms of retrieval, its not a great deal faster.
Here's a link to what I mean: Store pictures as files or in the database for a web app?
With regards to returning it to your Android app, you can send files in the response object (http://book.cakephp.org/2.0/en/controllers/request-response.html#cake-response-file):
public function sendFile($id) {
$file = $this->Attachment->getFile($id);
$this->response->file($file['path']);
//Return reponse object to prevent controller from trying to render a view
return $this->response;
}
This should give you finer control over what files are returned to your client.

How to send only "update" data from mysql to mobile device by PHP webservices?

I wonder how to send only "update" data to mobile device. Assume that I build mobile app for iOS and Android that uses PHP webservices to get data. When we start application first time it get all data form mysql database using json. But when we start it second time I don't want to delete old data on my mobile device and fetch all data one more time. I would prefer only to download "update" using php webservices from my database. Any ideas how to achieve this?

Getting data from MySQL to android and displaying as list under "App List" Tab?

I am a noob in android dev.. I have couple of questions..
1...I have database created in localhost in MySQL server. Table of all the "States".
Q2...I created PHP script to connect to the database, and getting the list from the database.. ...I need to convert this to Json file/data to be read in android...????
Q3...I created android project with tab views for list tab, getting & saving details tab, settings tab.. where details are settings tab are form view elements and need to write them back in json n send them to MySql database. how do i do that.. in php or android or both...?????
Q4.. When the user first installs the app and runs it, my app should send to the server the mobile registration id... how do it do that..?????
I tried C2DM, but no luck.. I am testing everything in the emulator first..
I am so stuck in these issues.. i have created more than 10 projects for each individual feature with the help of forums and blogs and google developer forums .. and yet dint succeed in anything..
PLZZZZZZZZZZZZZZZZZZZZZZZZZZ.... HELPPPPPPPPP!!!!!!!!!!!!?????
Thanks in adv..
Su
Q1. It is typical to use the json_encode() function to output a PHP array as a JSON object. This can be consumed by your android application by an AJAX call, passing in the URL to your PHP script.
Q2. Prepare an array of what you want to output as normal and then call json_encode() on it.
Q3. Look through the Android documentation and find a JSON encoding function. To 'send it to MySQL' you will need to pass the JSON output through an HTTP POST request to your PHP script that can validate the data and submit it to the database.

Categories