Can someone help me to solve this ? I'm trying to send data from android to MySQL using code below but I get error long cannot converted to String
. I can find plenty of solution related to no suitable method found .put(String)
but not in my case, so I decided to seek help from here. Any help would be appreciated.
public void addWorkForce(final String subcontractors, final String noPeople, final String noHours,final long twf)
{
class AddWorkForce extends AsyncTask<String, Void, String> {
ProgressDialog loading;
@Override
protected void onPreExecute() {
super.onPreExecute();
loading = ProgressDialog.show(WorkDetailsTable.this, "Please Wait",null, true, true);
}
@Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
loading.dismiss();
Toast.makeText(getApplicationContext(),s,Toast.LENGTH_LONG).show();
}
@Override
protected String doInBackground(String... params) {
HashMap<String, String> data = new HashMap<String,String>();
data.put(Config.KEY_SUBCONTRACTORS,subcontractors);
data.put(Config.KEY_NUMBERPERSONS,noPeople);
data.put(Config.KEY_NUMBERHOURS,noHours);
data.put(Config.KEY_TWF,twf);
RequestHandler rh=new RequestHandler();
String result = rh.sendPostRequest(Config.ADD_WORKFORCE,data);
return result;
}
}
AddWorkForce ru = new AddWorkForce();
ru.execute(subcontractors,noPeople,noHours,twf);
}
Error
Error:(281, 21) error: no suitable method found for put(String,long)
method AbstractMap.put(String,String) is not applicable
(argument mismatch; long cannot be converted to String)
method HashMap.put(String,String) is not applicable
(argument mismatch; long cannot be converted to String)