The concept we are covering here involve searching against mysql database. The following technologies are involved:
- HttpURLConnection
- MySQL Database
Add more examples if you have any.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Oclemy
Android PHP MySQL – ListView ServerSide Search/Filter
Android PHP MySQL ListView Server Side Search and Filter Tutorial
How to search and filter mysql data in the server database level from an android application. The widget we use is a simple ListView.
Hello guys,yes you can easily filter or search from an arraylist within your android application.But imagine a case where you have thousands of records in the server.Shall you download them all to an arraylist then filter them from there?? Doesn’t sound so efficient,isn’t it?
Relational Databases are tuned for performance by default and are much faster than filtering from Java code.So then today we discuss Android ListView MySQL – ServerSide Searh/Filter. In short we filter using our SQL statements and return the results back to the android. For more detailed explanations,please watch our video tutorial. Cheers.
NB/= For demo,setup and more explanations please have a look at our video tutorial here.
Our MainActivity Class
Our Connector Class
Our SenderReceiver Class
Our DataPackager Class
Our Parser Class
Our Layouts
(a) . Our ActivityMain layout
(b). Our ContentMain layout
Our Manifest
Our PHP file
Oclemy
Android PHP MySQL RecyclerView – ServerSide Search/Filter
Android PHP MySQL – Android MySQL RecyclerView – ServerSide Search/Filter Tutorial
This is an Android MySQL Search tutorial. We are performing search on the server side against our MySQL database. Our widget is RecylerView.
The world we live in is indeed large.The data we have is in astonishing quantity.Even programming,atleast in most cases involve manipulating or reading some data.
This tutorial is no exception.Our aim is to see how to filter data from our MySQL database.Then we show our results in Realtime. We are performing a server-side search.Generally speaking,this is much faster than filtering at the client.Its faster than say,downloading your data to the device,then filling some sort of arraylist.
Then filtering the arraylist.What if am having 100,10000,1 million records etc.You get the point. You’ll hog the users bandwidth.And it takes time.Writing optimized java code to search can be tricky itself.Now we can save ourselves some trouble.Perform the search on the big beefy servers.
Then download results.SQL is normally optimized for search/select performance.And we trust it better than ourselves. Anyway we use
java.net.HttpURLConnection
class,a subclass ofjava.net.URLConnection
.Demos
HttpURLConnection
Read about HttpURLConnection here.
Sending Data
setDoOutput(true)
to allow connection.Receiving Response
setDoInput(true)
to allow connection.PHP Code
Java Code
Our Connector Class
Our DataPackager Class
Section 3 : Our SenderReceiver Class
SenderReceiver
class.onPreExcecute()
and dismissing immediatelyonPostExecute()
is called.OutputStreamWriter
.OutputStreamWriter
instance,we pass toBufferedWriter
instance.bufferedWriter
instance writes our data.bufferedreader
instance.Section 4 : Our Parser
JSONObject
andJSONArray
are sufficient for us.So we use them.Our Recycler Package
This is the package where we deal with RecyclerView stuff. It contains:
(a). Our MyHolder
(b). Our MyAdapter
Our MainActivity
Our Layouts
(a). activity_main.xml
(b). content_main.xml
Section 7 : Reminders