At the moment I can add users into the database through postman or emulator but I need to be able insert the data from actual android device .What adjustments do I have to take ? Please have a look at the code below
This is my main activity that I using in my app :
package ie.example.artur.adminapp;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import java.util.HashMap;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class MainActivity extends AppCompatActivity {
    EditText editTextName,editTextEmail,editTextPassword;
    TextView textView;
    private static final String DB_URL = "jdbc:mysql://10.3.2.51/socialmedia_website";
    private static final String USER = "zzz";
    private static final String PASS = "zzz";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_register);
        findViewById(R.id.layoutProgress).setVisibility(View.GONE);
        textView = (TextView) findViewById(R.id.textView);
        editTextName = (EditText) findViewById(R.id.editTextName);
        editTextEmail = (EditText) findViewById(R.id.editTextEmail);
        editTextPassword = (EditText) findViewById(R.id.editTextPassword);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                        .setAction("Action", null).show();
            }
        });
    }
    public void btnConn(View view) {
        findViewById(R.id.layoutProgress).setVisibility(View.VISIBLE);
        final ApiClient apiClient = new ApiClient();
        String email = editTextEmail.getText().toString();
        String name = editTextName.getText().toString();
        String password = editTextPassword.getText().toString();
        HashMap<String,String> parameters = new HashMap<>();
        parameters.put("email",email);
        parameters.put("name",name);
        parameters.put("password",password);
        Call<ApiResponse> call = apiClient.loginUser(parameters);
        call.enqueue(new Callback<ApiResponse>() {
            @Override
            public void onResponse(Call<ApiResponse> call, Response<ApiResponse> response) {
                if(response.isSuccessful())
                {
                    ApiResponse apiResponse = response.body();
                    if(apiResponse.getStatus() == 200 || apiResponse.getStatus() == 201)
                    {
                        findViewById(R.id.layoutProgress).setVisibility(View.GONE);
                        Send objSend = new Send();
                        objSend.execute("");
                        //Toast.makeText(MainActivity.this,"Success", Toast.LENGTH_SHORT);
                        textView.setText("Success.");
                    }
                    else
                    {
                        //Toast.makeText(MainActivity.this,apiResponse.getErrors(), Toast.LENGTH_SHORT);
                        textView.setText(apiResponse.getErrors());
                    }
                }
                else
                {
                    findViewById(R.id.layoutProgress).setVisibility(View.GONE);
                    //Toast.makeText(MainActivity.this,"Invalid api response.", Toast.LENGTH_SHORT);
                    textView.setText("Invalid api response.");
                }
            }
            @Override
            public void onFailure(Call<ApiResponse> call, Throwable t) {
                findViewById(R.id.layoutProgress).setVisibility(View.GONE);
                //Toast.makeText(MainActivity.this,"No host available or please check network connectivity.", Toast.LENGTH_SHORT);
                textView.setText("No host available or please check network connectivity.");
            }
        });
    }
    private class Send extends AsyncTask<String, String, String>
    {
        String msg = "";
        String name = editTextName.getText().toString();
        String email = editTextEmail.getText().toString();
        String password = editTextPassword.getText().toString();
        @Override
        protected void onPreExecute() {
            textView.setText("Please Wait Inserting Data");
        }
        @Override
        protected String doInBackground(String... strings) {
            try {
                Class.forName("com.mysql.jdbc.Driver");
                Connection conn = DriverManager.getConnection(DB_URL, USER, PASS);
                if (conn == null) {
                    msg = "Connection goes wrong";
                } else {
                    String query = "Insert INTO users (name,email,password) VALUES('" + name+"','"+email+"','"+password+"')";
                    Statement stmt = conn.createStatement();
                    stmt.executeUpdate(query);
                    msg = "Inserting Successful!!";
                }
                conn.close();
        }
        catch(
        Exception e
        )
        {
            msg = "Connection goes Wrong";
            e.printStackTrace();
        }
        return msg;
    }
@Override
    protected void onPostExecute(String msg) {textView.setText(msg);}
    }
}
Api client class
package ie.example.artur.adminapp;
import java.util.HashMap;
import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Call;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
/**
 * Created by asifj on 7/25/2017.
 */
public class ApiClient
{
    private String BASE_URL = BuildConfig.BASE_URL;
    ApiEndPoints apiService;
    public ApiClient() {
        HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
        OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
        logging.setLevel(HttpLoggingInterceptor.Level.BODY);
        httpClient.addInterceptor(logging); // <-- this is the important line!
        Retrofit retrofit = new Retrofit.Builder().baseUrl(BASE_URL).addConverterFactory(GsonConverterFactory.create()).client(httpClient.build()).build();
        apiService = retrofit.create(ApiEndPoints.class);
    }
    public Call<ApiResponse> loginUser(HashMap<String, String> parameters)
    {
        return apiService.usercreate(parameters);
    }
}
If you need me to share any more class please let me know in the comments
 
     
     
    