Mysql
 SQL >> Database >  >> RDS >> Mysql

Sincronizzare un database SQLite Android con un server MySQL remoto

Un approccio è inviare i dati a una pagina PHP del tuo sito tramite GET o POST, che poi li scrive su MySQL sul server remoto, così:

 HttpGet request = new HttpGet(url); ResponseHandler<String> responseHandler = new BasicResponseHandler(); HttpClient client = new DefaultHttpClient(); String response = client.execute(request, responseHandler); 

L'url potrebbe essere qualcosa come www.mysite.com?id=5&name=john ... Il tutto va eseguito dentro il doInBackground di un AsyncTask. La parte difficile è capire quanti record puoi caricare per volta.

È anche facile fare in modo che il server remoto generi su richiesta un file XML che Android scarica, usando una richiesta simile a quella qui sopra.