Android Application With SQL Server using Web Service Part 3


Welcome again, with Android SQL Server Web Service Connection.

In the last Article we stopped with many errors, I know that, don't worry again.

its just because of SOAP package, you need to include it to your project.

Just Change your Android Studio to Project and go to 

Your Application Name >App >Libs.... 

Just past SOAP package to this path.

after again page to Android.

Until now still you have same errors still, you need to add SOAP package to your Gradle

Gradle Scripts >build.gradle(Module: app)

just add this line(there is one more way to add but use this for now) :

compile files('libs/ksoap2.jar') 

The last thing you need to do is, add this code to Main Activity.



Now, We can say you can run your App.

Be happy,

 if you find any error just post it on the comment or text me to my facebook page.


Source Code: you can find it, in my GitHub Account.

Youtube Video on My Channel.




Android Application With SQL Server using Web Service Part 2


Hi, again to our second part from Android SQL server Web Service.    

After Create 2 Activities Home and log in.

will work on Login because it's our main jobs .

The design will look like this Photo :

I'm sure 100% you can do better than my design ;).

Code in XML .

Don't worry, if you can't copy the code. 

it's on My GitHub Account or First part from this tutorial. 

Eazy and simple till now.

Next Step, not that simple, in your Login Java Class. 

You need to declare and link your layout Component to you Java Code.

Same as this  Photo.

Now, 100% you will get errors in your code, because of  MyAsyncTask() Class, does not Exist, so declare it like this ,

private class MyAsyncTask extends AsyncTask<String,Void,String>
protected String doInBackground(String... strings) {}
protected void onPostExecute(String result) {}

 In the doInBackground method, will be the connection or create Connection String to your Database.

Add this code to :

protected void onPostExecute(String result) {}


part 3

Android Application With SQL Server using Web Service Part 1



In this Article will talk about SQL Server, how to connect to SQL Server Live Database.

but this time will not .NET or Microsoft Tools to read or write andy data from our database.

Today will be Android Application.

will use Android Studio 2.3.3 or Higher for this Application.

So, how to connect to SQL database, its very simple not simple same as, .NET

maybe SOAP package will make it easy. 

Our Project will be Login  Application.

will content 2 parts :

1- ASP.NET Web Service.

  Youtube Link  GitHub Project . 

In this article, I'm not going to talk about Web Service.

2- Android Application, How to Login with Email and Password with Live SQL Database. 

 Youtube Link    GitHub Project 1 .  GitHub 2

Will have  2 Activities and Layouts. 

1- Main Activity or Home Activity this will be opened if the result of login True.

2* Login Activity, this one will have 2 EditText for Email and Password,

and sure one Button For Sign In. 

Let's Start our Android Application with creating a new project.

New Project

- Choose a name for your project.

-  Will Generate New Empty Activity and Layout.

So, this one will Be Home Activity as I mention it will open if the Email and Password True.

You can create any Text View and write in it Welcome or Hello World :).

-Let's create one more Activity and call it Login Activity, this will be for the main job.



part 2


List View - Android Part 2


You can use this adapter when your data source is a database Cursor. When using SimpleCursorAdapter, you must specify a layout to use for each row in the Cursor and which columns in the Cursor should be inserted into which views of the layout.

For example, if you want to create a list of people's names and phone numbers, you can perform a query that returns a Cursor containing a row for each person and columns for the names and numbers. You then create a string array specifying which columns from the Cursor you want in the layout for each result and an integer array specifying the corresponding views that each column should be placed −

String[] fromColumns = {ContactsContract.Data.DISPLAY_NAME,
int[] toViews = {,};

When you instantiate the SimpleCursorAdapter, pass the layout to use for each result, the Cursor containing the results, and these two arrays −

SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
   R.layout.person_name_and_number, cursor, fromColumns, toViews, 0);
ListView listView = getListView();

The SimpleCursorAdapter then creates a view for each row in the Cursor using the provided layout by inserting each from Columns item into the corresponding toViews view.

List View - Android Part 1


Android ListView is a view which groups several items and display them in vertical scrollable list.

The list items are automatically inserted to the list using an Adapter.

 that pulls content from a source such as an array or database.

An adapter actually bridges between UI components and the data source that fill data into UI Component. Adapter holds the data and send the data to adapter view, the view can takes the data from adapter view and shows the data on different views like as spinner, list view, grid view etc.

The ListView and GridView are subclasses of AdapterView and they can be populated by binding them to an Adapter, which retrieves data from an external source and creates a View that represents each data entry.

Android provides several subclasses of Adapter that are useful for retrieving different kinds of data and building views for an AdapterView ( i.e. ListView or GridView). The common adapters are ArrayAdapter,Base Adapter,CursorAdapter, SimpleCursorAdapter,SpinnerAdapter and WrapperListAdapter. We will see separate examples for both the adapters.


You can use this adapter when your data source is an array. By default, ArrayAdapter creates a view for each array item by calling toString() on each item and placing the contents in a TextView. Consider you have an array of strings you want to display in a ListView, initialize a new ArrayAdapter using a constructor to specify the layout for each string and the string array −

ArrayAdapter adapter = new ArrayAdapter<String>(this,R.layout.ListView,StringArray);

Here are arguments for this constructor −

  • First argument this is the application context. Most of the case, keep it this.

  • Second argument will be layout defined in XML file and having TextView for each string in the array.

  • Final argument is an array of strings which will be populated in the text view.

Once you have array adapter created, then simply call setAdapter() on your ListView object as follows −

ListView listView = (ListView) findViewById(;

You will define your list view under res/layout directory in an XML file. For our example we are going to using activity_main.xml file.


Following is the example which will take you through simple steps to show how to create your own Android application using ListView. Follow the following steps to modify the Android application we created in Hello World Example chapter −


Following is the content of the modified main activity file src/com.example.ListDisplay/ This file can include each of the fundamental life cycle methods.

package com.example.ListDisplay;
import android.os.Bundle;
import android.view.Menu;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class ListDisplay extends Activity {
   // Array of strings...
   String[] mobileArray = {"Android","IPhone","WindowsMobile","Blackberry",
      "WebOS","Ubuntu","Windows7","Max OS X"};
   protected void onCreate(Bundle savedInstanceState) {
      ArrayAdapter adapter = new ArrayAdapter<String>(this,
         R.layout.activity_listview, mobileArray);
      ListView listView = (ListView) findViewById(;

Following will be the content of res/layout/activity_main.xml file −

<LinearLayout xmlns:android=""
   tools:context=".ListActivity" >
      android:layout_height="wrap_content" >
Following will be the content of res/values/strings.xml to define two new constants −
<?xml version="1.0" encoding="utf-8"?>
   <string name="app_name">ListDisplay</string>
   <string name="action_settings">Settings</string>
Following will be the content of res/layout/activity_listview.xml file −
<?xml version="1.0" encoding="utf-8"?>
<!--  Single List Item Design -->
<TextView xmlns:android=""
   android:textStyle="bold" >

Let's try to run our modified Hello World! application we just modified. I assume you had created your AVD while doing environment set-up. To run the app from Android studio, open one of your project's activity files and click Run Eclipse Run Icon icon from the tool bar. Android studio installs the app on your AVD and starts it and if everything is fine with your set-up and application, it will display following Emulator window −