Skip to main content


How to check Network Availability

On this blog I am going to explain how to check internet connection is present or not. For this we are  using ConnectivityManager and NetworkInfo. For this first you need to add the permission on your AndroidManifest.xml file. 
Adding Permission We required INTERNET and ACCESS_NETWORK_STATE. We need to add these permisions inside <application> </application> tag. Here is the permission code.

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

Java Code
I created a function  isOnline(Context con) to check the internet is there or not. This function will return the network status if the internet is connected or not.

public static boolean isOnline(Context con) {
    boolean connected = false;
    ConnectivityManager connectivityManager;
    try {
        connectivityManager = (ConnectivityManager) con.getSystemService(Context.CONNECTIVITY_SERVICE);
Recent posts

How to get onBackPressed() in a Fragment page.

In this Blog I am going to explain how to trigger Back button press (onBackPressed()method) event on my fragment page.  I am doing this with the help of  an "interface" in java. For this I am creating an Activity Class and a Fragment Class. 

HomeScreen (Activity Class)

      In this class we created an interface "OnBackPressedListener" to detect the back press.  When  it execute onBackPressed() event it will execute the interface method "doBack()" which will trigger the event on the Fragment page.

public class HomeScreen extends Activity {
    protected OnBackPressedListener onBackPressedListener;
    public interface OnBackPressedListener {         void doBack();     }
    public void setOnBackPressedListener(OnBackPressedListener onBackPressedListener) {         this.onBackPressedListener = onBackPressedListener;     }

    @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.ho…

How to parse a json file In Android

In this blog I am going to explain How to parse a json file. Here I am going to explain how to parse a json file stored in Asset folder. Here my file name is user_details.json which stored in asset folder(json_file/user_details.json). Here is my json file.
  "Name": "Shidhin TS",
  "UserId" : "1",
  "Website" : "",
  "Company" : "B-Mates Technologies",   "Mobile" : "+91XXXXXXXXXX",
  "Qualification": [
            "Name": "Name1",
            "Institute": "Institute Name1",
    "Year": "2006 - 2009",
            "Mark": "87%"
            "Name": "Name2",
            "Institute": "Institute Name2",
    "Year": "2004 - 2006",
            "Mark": "78%"

How to call a webservice in android.

In this blog I am going to explain How to call a .Net xml webservice in android with the help of an login WebService.
XML RequestPOST /Service.asmx HTTP/1.1
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: ""

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="" xmlns:xsd="" xmlns:soap="">
    <Login xmlns="">

                  In this WebService request Our Function name is  "Login " and the parameters we are passing are "Email" which is "string" format and  "Password" which is also in &q…

SQLite Database in android

In this blog I am going to explain SQLite database in android. It is an Open Source Database, Also Its is embedded to all the android devices so there is no need to add any library to the application. You are need to import SQLiteDatabase and SQLiteOpenHelper for that.

import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

Also I an going to explain How to create a Database, Tables, Inserting values, Updating values, Deleting values from the Database operations in Android.

More Information about SQLite :
More Information about SQLite Data-types:

Creating Database

     First you are needed to create a class for database. Here I am going to create a class "DbHelper".

public class DbHelper {


Now I need to extend SQLiteOpenHelper on this class. While extendingthis we need to add constructor and some unimplemented methods. Also I am going to declare the "DATABASE…

AsyncTask in Android.

AsyncTask  is one Class which is used to perform background processes without having threads. For an AsyncTask is having 4 steps. onPreExecute, doInBackground, onProgressUpdate, onPostExecute

onPreExecute method is invoked first while calling the AsyncTask. Here comes the fuctions which are to be performed at the starting. The functions such as  showing progress dialog etc..

doInBackground method will execute after onPreExecute method. Here comes the functions which are to be done in background. The functions such as downloading files uploading files etc...

onProgressUpdate method is invoked while the progress is changed. Here we will write the code to perform the action while changing the progress.

onPostExecute method is invoked after the doInBackground method is completed. This method will execute at last. Here we will write code to perform the actions at last. The functions such as progress dialog dismiss, parse the result, redirection to another page etc..

Here is One Example:


SharedPreferences In Android.

SharedPreferences SharedPreferences is one of the storage mechanism in Android. The value we are storing inShared Preferences is permanent so the value stored will remains there when we close the application. Here the storing of data is done as key value pair. Here we store the data with the help of an editor.  To get the value we have saved we need to call getSharedPreferences() method.

Here I am going to Explain How to save the details Id, Name, Designation, Phone number of an Employee in  SharedPreferences.

Here Am going to create a class EmployeeSession to store the details,

public class EmployeeSession {

      private static final String  SharedPreference_Employee = "Employee_Preferences";
     // Employee_Preferences is the Name of the SharedPreferences.

    private static final String Emp_Id = "EmployeeId";
    private static final String Emp_Name = "EmployeeName";
    private static final String Emp_Designation = "EmployeeDesignation";