sqlite database is private to the application. So if you want to access your sqlite database in any other application, you can use content provider. Even there are some benifits of using content provider private to your app e.g. if you are using CursorLoader or sync adapter in your app.
First we need to declare content provider in AndroidMenifest.xml file
Continue reading “Android Content Provider” »
In this post we will discuss how to store data in the android sqlite database. Android is using light weight open source sqlite database as one of the way to store data. Android provides two important classes SQLiteDatabase class to perform common database management tasks e.g. create, delete, execute SQL commands,etc and a helper class SQLiteOpenHelper to manage database creation and version management.
Continue reading “Android SQLite Database” »
In this post we will discuss about creating datepicker using DialogFragment. Google recommends that we use DialogFragment instead of simple dialog with Activity.showDialog. DialogFragment will automatically manage life cycle for us.
1. Create class for date picker dialog fragment
a. define a public default constructor otherwise it will crash on screen rotation.
b. Define the onCreateDialog() method to return an instance of DatePickerDialog
c. pass OnDateSetListener to the constructor of DatePickerDialog.
Continue reading “Android Date Picker DialogFragment” »
Before android 3.0, users used to press hardware menu button, to see what all actions are available for current screen.
As of android 3.0, the hardware menu button is not available on android devices and options menu is replaced by action bar.
Actionbar is a bar on top of the activity. It can provide actions and navigation using views.
We can add custom views to actionbar using setCustomView method that takes View as argument. for that first we need to enable DISPLAY_SHOW_CUSTOM option.
In this article we will see how we can create custom actionbar (save and discard actionbar).
Continue reading “Android custom save and discard type ActionBar” »
As a mobile developer for end-to-end apps we need to interact with the server. Even if your mobile app is not server client based app, we need some minimum interaction with the server like user authentication, user profile saving on server, etc.
So its good to have some idea about development of web services. In this article we will see how easily we can develop RESTful web services using jersey.
Continue reading “Creating RESTful web services using jersey” »
In this example we will combine some features of android like proximity sensor, voice recognizer and TTS.
Proximity Sensor: is sensor that can recognize presence of nearby object. we will user this sensor to start voice recognition. So when you take you android device near to your face, proximity sensor will start the voice recognizer.
Voice Recognizer: can convert speech to text. So when you give the voice command, its will return an array of matches and will start TTS.
TTS(Text To Speech): can convert text speech. In this application we will use TTS to listen voice command response.
Continue reading “voice command example using proximity sensor, voice recognizer and TTS in android” »
In my previous post, What is Intent in android? I have disused about intents. In that post we have seen that there are two types of intents.
1. Explicit intents: We can call target component by its name.
2. implicit intents: We can call a target component on the basis of what we want to perform.
In this post we will see, how does implicit intent work?
According to google intent filter is “To inform the system which implicit intents they can handle”
e.g. you have more that one activities in your application and you know that there is no “main” method in android application. So how activity launcher will know that which activity to start first.
Continue reading “What is intent filter in android?” »
For definition of java annotation i can’t think a better definition than wikipedia “An annotation, in the Java computer programming language, is a special form of syntactic metadata that can be added to Java source code. Classes, methods, variables, parameters and packages may be annotated. Unlike Javadoc tags, Java annotations can be reflective in that they can be embedded in class files generated by the compiler and may be retained by the Java VM to be made retrievable at run-time.” http://en.wikipedia.org/wiki/Java_annotation Some of the java programmers use annotations without even know about annotations. When ever you override any method of super class in you class, eclipse automatically adds the @override annotation above method name.
Continue reading “Custom Annotation in Android” »
Now a days almost every smartphone applications use location based functionalities. But every articles say that disable wifi, 3g, gps etc for battery saving. So for every location based applications lots of problems are there like. What are location providers available in device? You can enable GPS using some method but best methods is ask user to enable location providers.
In this post we will see that how can we prompt user to enable location providers.
Continue reading “Prompt user to enable location providers in Android” »
You are developing game apps, business apps or any app you need EditText widget for taking input from users. Android EditText widget is functionally rich and customizable.I have worked on many platforms and i have noticed that on most of the platforms you have do lots of coding for UI customization. But in android you can easily customize UI elements as per your requirements. In this post i am trying to collect most of the information about android EditText. EditText is the subclass of TextView class.
Like other widgets you can add a simple EditText
Continue reading “EditText in Android” »