Android Https Post and Get

Yesterday, i have done an piratical test for an interview. The task provided is to post a username and password to an https url and also to  get the response results using an https connection in another url. I have successfully completed the task, but it took me around five hours. I wasted lot of time in researching on how to do an https post. Therefore i thought i could share some of the important information, so that it will we helpful for some one. please not i am not going to share the entire solution.

First create an custom socket factory inside your package. Use the below code.

Add this function inside your MainActivity class to create a httpClient using custom socket factory. As shown in the below code.

Then Run an Async task for https post like this.

And if you want to do an https Get request. See the code below

Hope this helps. Feel free to ask any question if you have in the comments section below.Tnx, Happy coding 🙂

mysql get the existing table code

I had a situation where i have a table with huge lot of fields. i want to recreate this table with some other name. It would be very easy if i have any user interface like php myadmin or mysql work bench but since i am working on the server there is no UI. Therefore i was looking on the internet for a way to get the sql code for existing table, so that i can just recreate the table by just running a single command.

then i found this on My Sql Developer page

Here is the results

Screenshot from 2016-05-16 14-43-25

Now i just need to copy the existing code and change the name of the table to the name i want and then run the script. thats it.