An Overview of Android Binder Framework

In the Linux OS, there are several techniques to achieve IPC (Inter-process communication) like files, sockets, signals, pipes, message queues, semaphores, shared memory, etc. However, Android’s modified Linux kernel comes with a binder framework which enables an RPC (remote procedure call) mechanism between the client and server processes, where the client process can execute remote methods in the server process as if they were executed locally. So data can be passed to the remote method calls and results can be returned to the client calling thread. It appears as if the thread from the client process jumps into another (remote) process and starts executing in there (known as Thread Migration).

Continue reading “An Overview of Android Binder Framework”

Asynchronous Background Execution and Data Loading with Loaders (Framework) in Android

Android has this Loader framework that offers a powerful (yet simple) way to asynchronously load data from content providers or other data sources like an SQLite database, network operation, et al. in an Activity or a Fragment (clients).

Continue reading “Asynchronous Background Execution and Data Loading with Loaders (Framework) in Android”

Using AsyncQueryHandler to Access Content Providers Asynchronously in Android

In our previous posts we discussed SQLite access and Content Providers. Now access to a content provider will involve accessing some sort of persistent storage like a database or a file under the hood. Accessing a storage can be a long task and hence this should not be executed on the UI thread which will delay the rendering and could even lead to ANRs. Hence, background threads should be responsible for handling provider’s execution.

Continue reading “Using AsyncQueryHandler to Access Content Providers Asynchronously in Android”

Android Sharing Application Data with Content Provider and Content Resolver

In the previous article (must read) we discussed how basic CRUD operations can be done on SQLite in Android. An SQLite database is inherently private to the application that creates it. That means if you want some other app to access your data that won’t be possible. To solve this limitation (its more of a security measure actually), Android has the concept of Content Providers using which one app can give out constrained access to its structured set of data to other apps. So a content provider allows application to access its data which is mostly stored in an SQLite database. It is important to note that just because providers allow you to share data with other applications doesn’t mean that it cannot be used in the same application to access data.

Continue reading “Android Sharing Application Data with Content Provider and Content Resolver”

Working with SQLite Database (CRUD operations) in Android

We’ve covered data storage options like SharedPreferences and Internal/External Storage before. It’s time to look at another option which is basically SQLite databases. Most data-driven Android applications will need a solution to store structured (relational) data. If that’s the case then SQLite is an amazing option that Android supports out of the box. The SQLite database management classes/APIs are available in the android.database.sqlite package. We’ll learn how to create an SQLite database and then save data into it as well as retrieve, modify and delete data.

Continue reading “Working with SQLite Database (CRUD operations) in Android”

Understanding Android Started and Bound Services

In Android, a Service is an application component that can perform long-running operations in the background on the UI thread. By background, it means that it doesn’t have a user interface. A Service runs on the main thread of the calling Component’s process by default (and hence can degrade responsiveness and cause ANRs), hence you should create a new Thread to perform long running operations. A Service can also be made to run in a completely different process.

Continue reading “Understanding Android Started and Bound Services”