Android S7E3 : PHP MySQL - Multipart Upload and Download Images and Text - GridView

preview_player
Показать описание

This is an advanced tutorial that has been requested by alot of people and we want to put together in a very easy manner.

In this tutorial we want to see how to first upload images and text to MySQL database, the retrieve them and show them in a GridView. This is an android tutorial and our programming language is Java. The user will type name, description and choose an image from explorer using a Choose Dialog at runtime.

Then he clicks a button to send them to php mysql datatabase. As we upload we will show a progressbar. There is a button that when the user clicks a new activity is opened and data is automatically fetched from mysql database. The data is rendered in a custom gridview as images and text inside a cardview.

MySQL is an open-source relational database management system.

PHP is a popular general-purpose scripting language that is especially suited to web development.

Fast, flexible and pragmatic, PHP powers everything from your blog to the most popular websites in the world.

We will be using Fast Android Networking library as we promised so we add it's implementation statement as a dependency.

Fast Android Networking is an open source android HTTP library built by Amit Shekhariitbhu.

It's been growing in popularity very fast because it's not only fast but is also user friendly. Moreover it supports advanced capabilities and documentation is great.

hrough this library we can make a HTTP GET, HTTP POST, upload data to server, download data from server etc.

In this example we will see how to perform a multi-part upload of images to server. We also send associated text that will be saved in MySQL database.

We also see how to make a HTTP GET request and download the uploaded data from mysql to our gridview.

Our GridView will comprise CardViews with images and text fetched from MySQL database. So we need to add the CardView support library.

We will use Picasso ImageLoader to download our images from our server based on the retrieved URLs. Picasso will also cache these images and show placeholder images.

We are testing our app using an emulator. To do so also you need to keep several things in place. First the emulator is like a seperate computer in your machine. If you can access you server via localhost or 127.0.0.1 in you laptop/desktop, you cannot do the same in the emulator.

This because localhost address is used internally be the emulator. So normally people use 10.0.2.2 instead of localhost. This works in majority of emulators like the android emulator or bluestacks.

If you are using Genymotion, then use 10.0.3.2 if the above doesn't work.

I personally use Nox Player, which is fast enough for my slow and overworked machine. However, the above all don't work with Nox Player.

So in that case I use the IP Address of my machine. To obtain the IP Address you type ipconfig/all in the Command Prompt, then find the IPv4. It is normally something like this : 192.168.12.2.

For more info check the link we have provided above.
Рекомендации по теме
Комментарии
Автор

GET RE-USABLE FULL APP TEMPLATE - Create any CRUD app you like.

Oclemy here guys. I have just released a much needed course for performing all CRUD operations, search and pagination using Retrofit against MySQL. I have designed this to be a full working app that you can use as a template.

TARGET STUDENTS:
1. Beginners/Intermediates who want to create their first full app.
2. Programmers who want a practical guide to master Retrofit.
3. Students who have a looming assignment/project and want a quick easy to understand project they can modify.
4. Anybody who wants to create a full CRUD app based on any idea.

WHERE IS IT?

I have just released it in udemy course. It's a 70 lecture practical step by step guide, realtime coding from scratch as we explain. It's the only Android MySQL CRUD course on udemy.

WHY GET IT NOW?

2. Next week am releasing a version for Firebase with Images/Text Full CRUD with pagination and search, You will get source code for that for free before I upload it to udemy.



ProgrammingWizards
Автор

that was you!
i already bought your course keep it UP

zmemes
Автор

when i take picture in landscape mode returns null in android nougat
Please help me to solve this problem

waqarvicky
Автор

can you insert foto from camera?
i try to add camera, but size problem.. how can resolve this.. ty

dwinurrohman
Автор

I am getting a exception telling that please pick the image from the right place ...can anyone help me in that .

arunm
Автор

Thanks sir, witting more videos in php android

shababkm
Автор

Hello. Can you show code in placeholser.xml?

iorgankrat
Автор

Hello,

Can you please help, im getting the following error:

W/System.err: failed to 443) from /fec0::5dec:c30f:bd41:219c (port 49132) after 60000ms

moizmoiz
Автор

It says "_data" column does not exist

waqarvicky
Автор

Hello Sir! Thank you for your great tutorial!

But can you help me?

I got an error "org.json.JSONException:Value <!DOCTYPE of type java.lang.String cannot be converted to JSONArray".

I follow your tutorial from the beginning.. i don't know how to solve that problem. I hope you reply and help me to solve that problem, thank you

MuhammadRizki-ybsr
Автор

hi
i have a problem with the app when i try to interact with the server. this is the error who appear
"UNSUCCESSFUL:ERROR to 10.0.0.3.2 not permited by network security policy" . if someone has a solution pls im waiting. thanks

wilfriedtouedi
Автор

how can i resolve the error cannot be converted to JSONObject"

venkateswarlumaturi