RUVIDEO
Поделитесь видео 🙏

Android PHP Mysql Part 1

Hello Guys ,

Welcome to Virtual Education Channel,

This series is about Android Solutions

Today we will see how to connect Android to Mysql Database using Okhttp3 library and PHP webservices .

1] Create a New Project in Android Studio

2] To Add okhttp3 library in android studio go to following

http://square.github.io/okhttp/

You can download the jar file and add it in your libs folder or you directly place

compile 'com.squareup.okhttp3:okhttp:3.5.0' in gradle and sync.

Wait Untill sync is finished


3] Now create a layout file for user registration and simultaneously we will also make a database in mysql for storing of data.

You can set the layout perfectly by specfying all the attributes accordingly in relative layout

I have created a simple layout

4] Now let's create a database in phpmyadmin

5] Let add the code in main activity to load all the elements that we setup in activity and also load the okhttp3 library

//firstly we load the components in mainactivity.java

// let's see the below Code
OkHttpClient client = new OkHttpClient();
//load the okhttp library class and create is object

RequestBody body = new FormBody.Builder()
.add("Token",token)
.build();
//here , we have to add the fields that needs to be pass in php files


Request request = new Request.Builder()
.url("http://10.0.2.2/")
.post(body)
.build();

// we will have to connect to localhost , in android we do it using 10.0.2.2 , check that localhost is working or not in android emulator
we can see the localhost connected , if it is not working than check the internet connection is enabled , you can see
4g sign on above panel in android indicates that internet is working .

client.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
Log.i(TAG , e.getMessage());
}

@Override
public void onResponse(Call call, Response response) throws IOException {
Log.i(TAG , response.body().string());
}
});

// Now we will have to create php (Webservices) file to get the post values from android file

// ahh, sorry give the internet permission in manifest file before running the code
// All Done , Now run your code

Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Android PHP Mysql Part 1», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.

Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.

Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!

Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.