Tag Archives: getApplicationContext

What is Context in Android and What is the proper way to use it?

By | December 7, 2018

Lets see what a Context is… Context : Current State of the application. Context : Handle of the application. Context : Provides access to the resources, preferences, accessing database etc. Activity inherits from the Context. Context is the most important part of the Android application and its everywhere. If you wrongly use Context, it can… Read More »

How to BackUp user’s data programatically in Android?

By | January 25, 2018

Android’s Backup service allows you to persist the data in a Google cloud storage. Android does this with the help of a BackUpAgent in the SDK. If we want to backup the data, then extend the BackupAgent. Lets see how we can do this. Benefits Reduce user frustration Increase login-rate. Reduce support calls Minimize user… Read More »

Check if the Device is Charging in Android and the Power Source.

By | February 20, 2017

Your application peformance should be upto the mark. But it should perform differently not on the front end , but on the back end when it the device is connected to a power source or charging. Charging could be of from USB and from wire cable. When your device is charging itself , it is… Read More »

How to load a spinner with values from SQlite Database in android?

By | November 18, 2012

Here is a simple example showing how to load a database values in a spinner in android. OK we will start. This is the layout for the spinner row. spinner_row.xml This is the layout for the interface. activity_main.xml Now this is the MainActivity.java file that uses the spinner and the database. Join the Forum discussion… Read More »

How to read and write files to SDCARD and application SandBox in Android – A complete example?

By | September 6, 2012

Here is a complete example of How to read and write files to SDCARD and application SandBox in Android. First create a new project and inside the mainActivity paste this code. Now create another class named MyFile.java and copy this code into it. Now the layout for the xml file. Note you should give this… Read More »

How to stream an audio in Android?

By | August 14, 2012

This is a simple example to how to stream an audio in android. Here is the java code for that. This is the xml that contains the button. When you run this program you will see a button and on clicking on that button you will see a dialog with message “Buffering…..”. Once the buffering… Read More »

Creating a custom Sliding GalleryView with Paging in android

By | June 28, 2012

This is a simple example showing A sliding Gallery in android. This example shows a sliding gallery with a paging Control and a changing page text which also indicate the page change. Create a new project named “SlidingGallery” and copy this code into “SlidingGalleryDemo.java“. My Activity name is “SlidingGalleryDemo.java” here. Now create a new class… Read More »

How to read and write a text file that is stored in your application sandbox in ANDROID?

By | April 22, 2012

Hi all….. In this post I will show you how to read a text file in ANDOID. Let your file is in the your application sandbox of your ANDOID project, i.e the file’s location is /data/data/your_package_name folder. To view this folder -> open File Explorer and expand each folder. For this example to work first… Read More »

How to save CheckBox values in SQlite Database and Load it later?

By | March 13, 2012

Hello…….. This post is just a simple demonstration to show a way to store a checkbox value in a database and reload it. Here I am storing only a value of a single checkbox and reloading it. But you can make changes in the code to save the id and value of the checkbox in… Read More »

Send Data when Clicking on a Notification in Android?

By | March 10, 2012

Hello everyone… I have shown in my previous tutorials on how to create notification in android and cancel it. This is the post showing this . Now today I am going to show how to send data when you click on the notification message. Here I am creating two activities. One the main activity that… Read More »

How to check whether a video has completed playing in android?

By | January 6, 2012

Hello all… Today I will show you how to get notified when a video completes playing in android. PLease check this post for playing a video and the resources. First create a folder named “raw” inside the “res” folder and copy a video inside it. Now copy the xml from this link. For listening to… Read More »

How to avoid OutOfMemory Exception in android- Second Method?

By | July 24, 2011

In the previous tutorial I showed you one method to avoid OutOfMemory Exception in android. And In this tutorial I will show you another method. The reduceImageSize function in this code reduces the image to the desired size you want. Create a fresh project and copy this code into it. How to put images inside… Read More »

How to avoid OutOfMemory Exception in android?

By | July 23, 2011

Hello all.. The OutofMemory exception is a common exception in android when you select an image from a gallery or load Big Images in android. There are different methods to solve this problem. Today I will show you one of the method to solve this problem. The method I am going to explain here is… Read More »

SQLiteManager plugin for eclipse

By | April 18, 2011

When you are working on an Android application that stores data in a SQLite database.There arise many questions like where does this database file get stored on the filesystem ? How can we access the database? I will give solution to all these problems. I created the SQLite database from my previous post about Using… Read More »

How to use SQLite in ANDROID, A really simple example.

By | April 17, 2011

Hello ANDROID Lovers…….. In today’s tutorial I will show you how to deal with SQLite Databases in ANDROID. You know that SQLite are Lightweight databases which is maintained only on the client side. They don’t need a server. The SQLite databases are simply a file wrapped around with some stuff which helps us deal with… Read More »

How to get information about all the applications installed in your ANDROID Emulator or Phone? / How to use getPackageManager() in ANDROID ?

By | April 3, 2011

Hi all, In this tutorial I will show you how to get the information about all the applications installed in your ANDROID phone. What you have to do is create a ANDROID project inside the package pack.GetAllInstalledApplications amd name the java file “GetAllInstalledApplicationsExample.java” and copy the following code into it. Here the “getPackageManager().getInstalledPackages(0);” gets information… Read More »

How to set wallpaper in ANDROID?

By | February 17, 2011

Following example shows how to set a Bitmap as wallpaper in ANDROID. After running this code your wallpaper on the ANDROID phone will change. Make sure that you have an image named ‘my_wallpaper’ in your drawable folder. And You have to set this permission in the Manifest.