Android - send / receive data to online mysql database - java

I have an edit text and a button when the user type for example the word "hi"
I want to make when he clicks on the button the following steps
get the word in the edit text send it to mysql online database
on the database I will be having many conditions if the word is for example "hi it will send "hello" .. if "how are you" I'll send "good"
the the app receive the new string and print it.
what can i do is getting the text from the edit text and printing it
but how to send a certain value to online mysql database and if it is equal to the stored value it receive another value ?

What you are asking is very basic , a little try and you can do it yourself. Basically you need to take values from your EditText fields using getText method, then you will call a php , other server end api to send these values to your server using get or post methods .
Refer this link for more help this link

Related

How to handle emoji in java and save into database, Then display on UI

I am sending a request on third party api. and a getting response like ⌚ Test which is actually looks like ⌚ Test on third party UI. My question is. In which format emoji's i should save into database , and how i can display the same emoji on UI as well.
please help
For this you will need to find the correct encoding to store your string in your database.
Since I don't know which DB you're using, you can go trough this tutorial to understand how to define your column in DB to store the correct format. EXAMPLE

How to store and retrieve text data in a formatted way?

I am building my website using Java and the SQL Server database. It is just like Stack Overflow where I have to store questions, answers, comments and images.
I am not able to store the text in a formatted way in SQL Server's text data type. Neither I am able to display it in a formatted way like Stack Overflow does. All solutions I've found so far concerns only PHP and MySQL. No help for Java and SQL Server. When I retrieve the text to display on web page it's all a mess. All I want to display the question and answers on my website just like Stack Overflow does. I'm attaching an image of my display page here to explain my problem. It is the image of a text ousput display from my website.
Image of output display from my website
First off: from MSDN, the "text", "ntext" and "image" data types will be soon removed from SQL Server, so you should avoid using them.
For text, use varchar(max); for ntext, use nvarchar(max) and for image, use varbinary (max).
I know from developing SSIS packages that SQL Server processes text types as a stream of non-unicode characters. So what I advise you to try is:
Change your datatype to nvarchar(max), to support unicode characters, what might be your problem;
Try to convert your nvarchar(max) to a string type before displaying. You can cast the data using SQL Server, even in a stored procedure.

Java storing user preferences

I'm making a program with a simple GUI, where the user have to do the login before starting use the program.
I want to store username and password and, if the user check the "Remember me" checkbox, i want that he doesn't need to enter data next time.
I tried doing with Java Preferences API, this way:
private Preferences prefs = Preferences.userRoot().node(this.getClass().getName());
prefs.put("codCliente", txtCodCliente.getText());
prefs.put("username", txtUsername.getText());
prefs.put("password", DigestUtils.md5Hex(String.valueOf(txtPassword.getPassword())));
But if i close and reopen the app, if i print the content of variables, it returns "Null key" NullPointerException.
I tried to save them in a .properties file, but I don't want to overwrite every time the whole file, and if I try to use apache commons configuration, with setProperty, I can't put the value on the variables.
Which is the best way to store this kind of data?
Thank you all.
Yes preferences is really easy and good way of doing this , problem is that:
he doesn't need to enter data next time
That means he WONT PUT ANYTHING INTO TEXT FIELDS.
But if i close and reopen the app, if i print the content of
variables, it returns "Null key" NullPointerException.
What did you expected? You put this NULL values into preferences again as he starts his app again.
Problem is in your design
application starts->
read preference of checkbox state->
{reread login credentials} else {nothing} ->
show login ui , user enters credentials ->{compare credentials to whose with preferences} DONT STORE ANYTHING , why woud you store what user is trying to login with every single time you start application?
You only store credentials at user creation ,use encryption and store your data, for both name , and password.
In your question there is not enough code to help you out directly with code sample , you have problem with design , where you reading this information in your code? Why dont you post this part here? You only show us that you store soemthing , well ok , thats useless to person thats trying to help you out.
I recommend you to SIT DOWN, stop writing code , and write yourslef flowchart of your application startup and login process all the way with when you read/write anything to preferences etc.

Request.getParameter java to vb.net

I have a question about retrieving data from a client who is using java and i am using vb.net.
I am expecting a form posted to me and read the data.
My issues is when i do Request.Form("DATA") i get nothing from the client.
Now if i create a html form and post it to my url with the field "DATA" i can read everything fine. I can also loop through my form and see the field and the button if i right them out to the screen or to a text file. Code is below
response.write(Request.Form("DATA"))
OR
Dim entryName As String
For Each entryName In Request.Form
response.write("Entity Name: " & entryName)
Next
Either method above works fine for me but not for the client. When the client hits my page i see nothing at all no buttons no fields, nothing.
I am concerned he is not posting properly to me. I spoke with the developer and he said he would retrieve the data on his end by doing something like "Request.getparameter"
I do not know java at all but from what i read it sounds like "Request.getparameter" will grab any field out of a form or querysting that has the name specified aka my "DATA" field that i am looking for.
Can anyone explain to me what request.getparameter means in java and what the equivalent code would be in vb.net?
Again i do not know java at all and have searched on this for a while but cant quite find a definitive answer.
Thanks in advance.
It is correct that in Java, request.getParameter("DATA") will look in both the query string and posted form data, while in .NET, Request.Form("DATA") only looks at posted form data. Therefore, it seems likely that your client is sending the data in the query string, since you are not seeing it.
You have a few options. You could use Request.QueryString("DATA") to check only the query string, or either Request.Item("DATA") / Request("DATA") or Request.Params("DATA") to check both the query string and posted form data, plus cookies and server variables. I think Items and Params may be a little different in what they return, e.g. for multiple values. They are probably the closest equivalent to the Java request.getParameter function.

Android database from website

i was wondering a few things.
I Have a database with 3 rows, and i have to use the database on my website cause it has to be shared with every one that downloads my app cause they can add more things.
Table is called
Poka
And the rows are
- ID
- word(TEXT)
- reply(TEXT)
The Reply is hooked onto the word.
Sense there can be more then 1 of the same "word" text i need it to search threw each of the word that was inputed in the EditText and pick a random reply from that and display it in EditText . And if there are no words, it will say cannot find one.
for that you have to use text box edit listener whenever the value of text box changes call the web service that give you response depend on what you send to it and then pass that response to text box.
refer therefer the answer of the question
in above link I explain the answer with code.Using that that code you can definitely do that.
the main thing is built web service so that it give you proper response.Just return table of words from the web service then catch that table get relevant column data and show it in your application.
obj3.getProperty(0).toString();//id
obj3.getProperty(1).toString();//word
If you returning id and word nad you want only word column then you can choose
obj3.getProperty(1).toString();//word
all the answer is explain in above link.refer that too.
Please write comment if you are facing more problem in that.

Categories