last day (14 days later) » 

4:24 AM
0
A: Save data to server data base in Android give unexpected error and close

Hoàng Vũ NamAndroid thought this exception because you executed network task on main thread. You have execute this task on other thread by put it to an AsyncTask. new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(final Void... params) { loadSave(); ...

 
thanks can u publish full code set where i want to add this.. because i new to android
 
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show(); loadSave();
Change loadSave() by my code
 
i change code like you said but there is an error cannot find symbol class AsyncTask E:\android-google-maps-demo-master\app\src\main\java\com\example\mapdemo\MapDemo‌​‌​Activity.java Error:(212, 13) error: cannot find symbol class AsyncTask c Error:Execution failed for task ':app:compileDebugJavaWithJavac'. > Compilation failed; see the compiler error output for details. Information:BUILD FAILED
 
Have you imported AsyncTask to your class
 
thanks friend.. now it working without errors. but data is not save to DB.. why is that ?
Hi friend
did u have any idea why data is not save to db ?
 
4:26 AM
You have to ensure that your server works ok ffirst.
 
Yes. when i just run the php file with default data. it save to db
 
Ok, I will check save method
 
thanks friend
here my php code
require "DB_Connection.php";

$longi =$_POST["longi"];
$lati = $_POST["lati"];
$user = $_POST["user"];
$lisence =$_POST["lisence"];
$date = $_POST["date"];

$query1="INSERT INTO mapdata (longi,lati,user,lisence,date)
values ('".$longi."','".$lati."','".$user."','".$lisence."', '".$date."' )";




mysql_query($query1) or die ('Error :' . mysql_error());
did u get what is the problem ?
 
bufferedWriter.write(mydataurl);
i think this is post_data
Sorry because i am doing some business task
 
4:42 AM
oh its ok my friend
so how can i fix this problem
 
I don not know php
you can test your server by make a post request with PostMan (Chrome app)
to test your server
 
any other way to fix this or can u send me any sample code to save data to database
 
do u have php ? my server not support with java
 
I have not
:(
 
4:50 AM
using java can i directly save data to database without host java class in to server
 
i think cant
 
owh
ok my friend
thanks for ur help
:)
 

last day (14 days later) »