Slatedroid info

Everything about android tablet pc [slatedroid]

Want to start making money from Android Apps? Here’s what NOT to do

Posted by wicked November - 24 - 2015 - Tuesday Comments Off


Creating a successful Android app is a goal worth pursuing. If you can create a genuine hit, then you’ll have a source of passive income that can generate money while you sleep for years to come. What’s more, you’ll have the immense satisfaction of being able to tell people you’re an app developer; and of knowing that something you created is being used by thousands of people around the world.

There’s no feeling quite like seeing someone load up the app you made on their commute to work. But with so much competition, how can one person – sans a huge marketing budget – possibly stand out and have a hit? Unfortunately, there’s no one answer to that question. Instead then, let’s start with some of the things you definitely shouldn’t do when you’re getting started…

Become Jealously Protective Of Your Idea

Most people who want to start developing apps will have one ‘big idea’ initially. At some point, they get their ‘eureka’ moment and they just know that they’ve stumbled onto something that will make them rich and change the world!

Problem is, they don’t know how to program and they aren’t exactly great at using Photoshop or marketing themselves. In other words, they need help.

But this is where the catch22 comes in: how do you go about approaching people for help without the risk of them running off with your idea and making it for themselves? How do you avoid becoming the next Winklevoss story?

In other words, no one wants to steal your idea.

As a programmer myself, this is something I encounter regularly. People will often approach me to help them code their app but then refuse to tell me what the app is, or even what it involves.

How am I supposed to tell them whether I can help if they won’t tell me the nature of the project? How can I give them a rough quote or any advice? And if they have no experience with apps, why would I take time out of my day to meet them for coffee and sign an NDA?

Even some of my close friends refuse to tell me their app ideas for fear that I’ll steal them (I presume??). It’s rather insulting actually!

When it comes to app development, it’s genuinely the execution that trumps the idea. People you discuss your ideas with will either lack the technical know-how to steal them, or they’ll have their own projects on the go that they’re more passionate about (and likely halfway through development with). In other words, no one wants to steal your idea.

And in the rare case that they do? There’s nothing you can do to prevent them anyway – you’ll need to start talking about your app eventually! So your only real defence is to be the first and the best.

Play At “Business”

Arranging a meeting and getting someone to sign an NDA is a classic example of wantrepreneurialism.

Wantrepreneur” is a term that comes up a fair bit on business blogs at the moment. The portmanteau describes the kind of person who is more interested in looking like they run a business than they are in actually running one.

This ties in with the last point. Arranging a meeting and getting someone to sign an NDA is a classic example of wantrepreneurialism (wantrepreneurmanship?). Don’t arrange an in-person meeting with someone unless it’s the fastest and most efficient way to exchange information. Of course face-to-face meetings are useful for networking and building relationships but this won’t always be relevant if you’re just reaching out to someone to see if they’ll make a sound effect for you. Under those circumstances, a meeting would just be a waste of everyone’s time.

Keep ‘communication overhead’ to a minimum and consider the ROI (Return On Investment) you’re offering to the people you work with. Don’t make them jump through hoops to do business with you, it’s frustrating and they’ll likely just move on.

Likewise, there’s nothing wrong with being friendly and jokey in e-mails. And don’t use the plural ‘we’ when you’re addressing people unless you actually have a team. It’s transparent and it can be a bit cringey…

Try To Design The Next Facebook

When my friends do tell me their big app ideas, I often still find myself rolling my eyes (maybe that’s why they don’t want to share?). As soon as someone tells me that they’re building a social network, or something that requires accounts and private messaging, I face-palm. Building a social network as an app is hard work. Not only do you create more complications by requiring a server and more stringent security measures but you also need to build a user-base of several hundred before your app will be at all appealing. No one wants to join a social network with 6 other people!

periscope 3

Go and take a look at the new streaming apps Periscope and Meerkat. Even these apps, which have been getting massive media attention for the last few months, feel somewhat barren and empty. Apps like these are just a massive undertaking and while it’s great to dream big, it doesn’t make any sense for your first project.

Want to start making money from apps? Then start with something simple.

Want to start making money from apps? Then start with something simple. One of my first apps was a keyboard, which was followed quickly by a slideshow of parkour images and later a word count utility (back when there weren’t any other apps that included that function). They weren’t ground breaking but they only took a couple of days to make in each case and they let me get something out there fast that I could begin earning and learning from.

If you have some grand vision for ‘changing the way we do business’, start with something smaller first and build up to it.

Avoid Taking The Path Of Least Resistance

Once you’ve chosen a simple app idea for your first project, the next step is to start making it. Now you’ll be presented with a lot of options: you can use an app builder, you can use Android Studio, you can use Basic4Android, you can use Corona

All of these are tools and/or IDEs (Independent Development Environments) that facilitate the creation of your app’s code. If you’re creating a game meanwhile, you might choose to use Unity which streamlines the process by providing a ready-made engine and intuitive interface, while handling a lot of the physics and other code for you. Or you can always outsource the programming to a developer rather than handling everything yourself (more on this in a moment!).


So which is the best choice for building your app? That very much depends on the nature of the app, your time frame and your current level of expertise. But what’s key here is that you take the fastest and least complicated route. Don’t be a snob about tools that make things easier.

If you’re making a game for instance, then using Unity will save you a huge amount of time and the end result will be much more professional than if you’d done it all yourself. That’s because the physics engine in Unity has been created by a team of professionals and refined over several years – unless you can rival that amount of time and experience, then their physics engine will always be better than one you build. And seeing as it’s ready to ‘plug and play’, it really doesn’t make any sense to make life more difficult for yourself. Even using a simplified app builder is fine if your app only needs to convey information.

For those of you familiar with web design, this is the equivalent of building your own website from scratch versus using WordPress. WordPress, like Unity or certain app builders, will allow you to build something more professional in a fraction of the time.

You can find out more in our guide: I want to develop Android Apps – What languages should I learn?

Do Everything Yourself

Asking for help is also very important. Don’t try and make all the graphics yourself unless this is something you’re specifically good at. The same goes for the sound.

You can find good graphic designers on Fiverr, UpWork or Elance and again they’ll be able to make something much more professional in far less time. Focus on what you’re good at and let others handle the rest.

If you’re going to hire a developer though, then take extra measures to make sure they’re good at what they do before you commit. Ask to see samples of their work and look for someone local wherever possible so you can speed up the refinement process.

Skip The Validation Process

Even if you’re creating a small app in the easiest way possible, you’re still going to be investing a fair amount of time and/or money into its creation. That’s why it doesn’t make sense to start building until you know for sure that there’s a market out there for you (or until you’re as sure as you can be).

This is called ‘validating’ the idea – which essentially means getting proof that there is sufficient interest in what you’ve got planned to make the development worthwhile.

I knew someone who spent two years building an app, hired a legal team and even paid to trademark the name; only for the final product to sell about three copies…

Taking to Kickstarter is a fantastic way to validate an idea and to get funds for hiring coders and designers (though it still doesn’t guarantee success). Alternatively, you might take the ‘fail fast’ approach where you release your MVP (minimum viable product) to test the market before investing more time and effort to develop it further.

There are other strategies for validating an idea too: such as conducting surveys, asking around on forums, building a mailing list or looking for similar apps to yours to see how they’re performing.

Think as well about your ‘route to market’ and any contacts you may already have that you can work with. If you happen to know the editor of Gardening Weekly, then making an app aimed at gardeners might just be a smart move. I made one app with a very popular YouTube vlogger and that meant I could be fairly certain it would reach a large audience. With the risk mitigated, that allowed us to spend more time on the app prior to its initial launch.

In short, you need to consider how you’re going to sell your app before you create it and you mustn’t spend months and years building something unless you can be fairly sure it won’t flop. I knew someone who spent two years building an app, hired a legal team and even paid to trademark the name; only for the final product to sell about three copies…

As you might imagine, they rather quickly lost their enthusiasm for app development.

Conclusion: Keep It Simple!

If you’re building an app purely out of love/for the fun of it then you can disregard everything I just said. This article applies to those of you who want to start earning money from apps. If you’re looking to make this into a business so you can exit the rat race, or if you plan on supplementing your current income, then you should focus on ROI. That means assessing the risk against the potential profit to be made and it means finding ways to reduce your overheads – both financial and time-wise.

Try not to get carried away with app ideas that will change the world. You’re far more likely to make money from something simple and easy and there’s nothing wrong with that. For every Mark Zuckerberg, there are countless people who get rich from gardening apps or fancy calculators.

And the best part about this business model is that it’s highly repeatable. If the first app doesn’t make a splash, just rinse and repeat. It’s a lot of fun and you’ll learn as you go. If throw enough ideas at the wall – as long as they’re ideas you believe in – eventually something will stick!

Android Studio version 1.5 is now available in the stable release channel

Posted by wicked November - 21 - 2015 - Saturday Comments Off


Android Studio version 1.5 is all about performance. The update has surpassed the beta stage and is now rolling out to everyone.

A major purpose of this update was to fix problems “under the hood” as Google stated. A number of bug fixes have been made and stability improvements have been added. Developers will be glad to know that Google added the ability to use short names when code-completing custom views. In addition, Google also threw in some new features. On version 1.5, users can adjust the memory profiler to best assist you in detecting the common known causes of one’s leaked activities. Google has also added multiple new lint checks.

To update to version 1.5 on Windows or Linux, navigate to the navigation menu and you’ll see the help option, then click “check for update.” If you’re a Mac user running OS X, the update can be seen by opening Android Studio and clicking on “check for updates.” If you’re experiencing issues, Google has asked us to kindly provide feedback on their blog which is linked down below.

Click here to view the embedded video.

Source: Android Developers

Come comment on this article: Android Studio version 1.5 is now available in the stable release channel

[TA Deals] Save 87% on the Android Marshmallow Mobile Developer Course

Posted by wicked September - 15 - 2015 - Tuesday Comments Off


If you have a great idea for a smartphone or smartwatch app, but you don’t know how to bring it to life, then this course may be just what you need. The Android Marshmallow Mobile Developer Course on offer from Talk Android Deals will help you learn how to code, developing impressive new apps for both smartphones and wearables from scratch along the way. Best of all, the course is now discounted to just $24.99, a whopping 87% saving!

The course has more than 93 lectures as well as 14.5 hours worth of content to guide you on your way to bringing your unique app to life. Besides learning to code using Java, and creating apps from scratch at your own pace, you will also receive a certificate of completion once you have finished the course.

What’s included in the course:

  • Code Android M phone & smartwatch apps using Java with over 93 hours worth of lectures and 14.5 hours of content
  • Learn how to use Google’s main API’s when making Android apps
  • Understand the Wearable API to create apps for wearables
  • Learn to code in Java from scratch
  • Build five varied apps – from a weather app to a unit convertor
  • Navigate the process of publishing apps

There’s never a better time to jumpstart your career or to bring your dreams to life than right now, and for just $24.99, what are you waiting for?


[Talk Android Deals]

Come comment on this article: [TA Deals] Save 87% on the Android Marshmallow Mobile Developer Course

Android SDK tutorial for beginners

Posted by wicked August - 18 - 2015 - Tuesday Comments Off

Android SDK Download

Android is the world’s most used mobile operating system, so it is essential that there is an easy way to develop apps for it.  This is where the Android SDK comes in. The SDK, which now comes as part of Android Studio and includes sample code and the emulator, makes it easier than ever to develop for Android. So, let’s get started.

What is the Android SDK?

SDK Manager

The Android SDK is a software development kit that includes all the necessary libraries and files for developers to make apps for Android. The kit also includes sample code with working applications, and the Android Virtual Device Manager, which lets you test your app on any version of Android (or Android Wear) that you want.

There are different components that can be downloaded, including platform-tools and build-tools.

  • Platform-tools are used to support new and existing features of Android, including the Android Debugging Bridge, bmgr and logcat. The Android Debugging Bridge (ADB) can be used to see what is causing errors and what processes are running as well as other things. bmgr is a tool used to manage the backup manager on an Android device with an API level of 8 or higher. It can be accessed by using the ADB.
  • Build-tools are made to work with the Platform-tools but can be updated independently if needed. These include JOBB, ProGuard and zipalign. JOBB allows you to build encrypted and unencrypted APK expansions in OBB format. ProGuard is able to shrink and secure your app by removing unused items, renaming classes and the like, this makes it harder for people to reverse-engineer your app and it makes the overall size smaller which is also a bonus. Zipalign optimizes .apk files to start in a certain alignment relative to the start of a file.
  • The SDK-tools are required and are used no matter what version of Android you develop for, these include: build-tools, debugging-tools and image-tools along with others.
  • The Android Debugging Bridge (ADB) and fastboot are also included in case you ever need to get your device out of a jam as well. Fastboot can be used to flash or wipe partitions to your device in case something happens, this is very easy to do. The ADB can be used to troubleshoot issues with your device and apps.

What makes the SDK special is that everything you could ever need or want is just a few clicks away, and with Google’s excellent developer page, anything is possible. Updating is a breeze too, if an update is available, the SDK will let you know when you launch the SDK Manager. This is a helpful way to make sure everything is up to date as well as check to see if there are any previews to download and mess around with.

How to use the samples provided

Google provides some very helpful samples, if used correctly. Samples can be found in the SDK folder under “samples” then under the Android version you want to take the sample from. Android Wear samples have an extra subfolder known as “wearable”. In these samples Google provides basic outlines for how the user interface should look for that version of Android and other new API changes.

When the watch face API came out, Google added a great example on how to use a classic ticking second hand watch face and a mechanical watch imitating sweeping second hand watch face. You can learn a lot by using the samples and the official documentation that Google provides. You can run the examples using the AVD Manager and modify the code however you like before using the same techniques in your own app.

The samples covers areas such as connectivity, including basic networking and Bluetooth; gestures, including gesture detection and multi-touch; and the user interface, including ActionBars, Notifications, transitions, swiping and Immersive mode.

What is the AVD Manager and how to use it

AVD Madness

The Android Virtual Device Manager is a very special entity when it comes to developing apps and the Android SDK. The AVD Manager lets you create virtual Android and Android Wear devices that you can run your apps on. These virtual devices are stripped down versions of Android that can be configured to any screen size, resolution and even type of processor including ARM, MIPS and x86.

In the last year, Google and Intel have made it a lot easier to run an AVD by using Intel’s Hardware Accelerated Execution Manager (HAXM) which enables the AVD to run in “Fast virt mode”. This makes for a very smooth virtual environment rivaling an actual Android device. The only downside is that there is no official way for two AVDs to communicate with each other. For example, you can’t have an Android phone connect with an Android Wear device if both are AVDs. However, you can connect your real device to an AVD wear device.

How the SDK and Android Studio tie together

Android Studio is in a league its own, and getting to know its ins and outs is a must, Gary Sims explains how to writing your first Android app using Android Studio. Android Studio makes accessing the SDK and AVD Manager a breeze. The icons to access both are located on the top middle toolbar. Having the Android SDK integrated into Android Studio is a huge plus when it comes to productivity. For example, the Android Debugging Bridge works beautifully with Android Studio and the AVD Manager. If you were to create a Android Wear app that requires the connection of a phone for data you could connect your phone and start an AVD of a wear device, connect the two and see exactly what is happening on each simultaneously. This is something that you will find hard to live without after you have used it a few times.

Android Developer Newsletter

Do you want to know more? Subscribe to our Android Developer Newsletter. Just type in your email address below to get all the top developer news, tips & links once a week in your inbox:

PS. No spam, ever. Your email address will only ever be used for Android Dev Weekly.


The Android SDK is a very powerful tool for creating simple apps to complex games. The SDK, AVD Manager and Android Studio work wonderfully together. Using the samples and documentation provided by Google anything is possible. It has never been easier to develop for Android. So why not start? You can pick up the Android SDK here.

Google shows off Android M’s Auto Backup for Apps function in video

Posted by wicked July - 30 - 2015 - Thursday Comments Off


One of the great things about flashing a custom Rom on your Android device is being able to backup and restore your apps via the custom recovery or by using an app such as Titanium Backup, it’s especially helpful if you’ve had to factory reset your device or if you’ve swapped over to a new device. Now it seems like un-rooted users will also be able to automatically backup and restore their apps thanks to a feature called ‘Auto Backup for Apps’ that is present in the latest Android M Preview.

Google’s Matthew Jav Williams takes us on a video run through of the Auto Backup for Apps feature, telling us that the apps user data will be automatically backed up and stored in Google Drive with a 25mb limit. The app backups will not count as part of your Google Drive quota. If you’ve installed apps on your device either from a third-party app store or by side-loading, don’t worry, they will also be backed up because the Auto Backup for Apps function isn’t directly tied to the Google Play Store.

Backups will occur when:

  • It is night-time
  • The device is charging
  • The device is connected to WiFi

Developers can include this feature into their apps by re-building their apps with version 23 of the SDK, they can also choose to opt out of including the auto backup function as well as choosing not to back up sensitive data or device specific tokens. Matthew gives some coding examples in the video below which show how easy it is for developers to include the Auto Backup for Apps function.


Click here to view the embedded video.

Source: Google Developers Blog
Via: Phandroid

Come comment on this article: Google shows off Android M’s Auto Backup for Apps function in video

Best resources for Android Game Developers

Posted by wicked April - 30 - 2015 - Thursday Comments Off

Android game development can be fun albeit stressful. There are so many resources for game developers. Some resources cater to PC or console games, while others try to cover all game devices.

Some resources are therefore more useful to mobile game developers than others, while some resources are more useful to Android game developers than other mobile device types. Most game resources are gravitating towards a cross platform model, so most of these resources will be useful to game developers for other platforms, or those looking to develop portable cross platform games.


Before you begin development, you should have a basic understanding of the Android platform, and should know where to go for help if you get stuck. Here are a few useful sites:

Android Developer Blog
This is the official news and announcements for android developers, coming directly from the android team at Google. Every android application developer should, at the very least, visit regularly.

Stackoverflow is a question and answer site for developers. Most issues you run into while developing has been encountered by someone else before, and asked, and answered on stackoverflow.

UX Magazine
The User Interface and User Experience of your game is a very important part of your game, which you ignore at your own peril. This website contains a ton of articles, tips, tricks and resources to guide your Interface design

Game Engines


It is pointless re-inventing the wheel and writing your game engine. There are many game engines out there that do all the grunt work for you including moving sprites, handling collisions, physics, etc. Take the time to learn and use one of them for your game:

A widely used game engine, for mobile game development. As it’s name suggests, its used primarily for 2D games.

A free to use cross platform gaming SDK which can create apps for Android, iOS and Windows Phone. Based on the LUA language the SDK is easy to learn and includes a phone emulator which makes development easy on a Windows PC or a Mac.

A fantastic game engine, that also integrates with a physics engine. It is primarily a 2D game engine, although it can also be used for 3D game development.

Unity has become one of the most successful game engines for mobile games. Games developed with unity are portable across mobile devices, consoles, PC operating systems and the web. It has been used in a number of very popular games.

Unreal Engine
Another excellent game engine, developed and backed by Epic Software. Based on the engine used to develop the hugely popular and successful Unreal Tournament. Games developed with this engine are portable across mobile devices, consoles and PC operating systems.

Game Content (Graphics, Art and Music)


While the actual game play is very important, the game content is also very crucial to a game’s success. Here is a list of some of the places where you can get excellent game content for free, or purchase, as well as some places where you can get artists to work on your art:

Graphic Buffet
Contains a selection of 2D game graphics, assets, UI elements and more.

Lets Make Games
This is an excellent resource, containing links to assets for game developers. There are links to free and paid resources, including art, graphics, sound, music, models, animations and more. For both 2D and 3D games.

Super Game Asset
Has a selection of game art, including environment, characters, icons and more, mainly for RPG games

Unity Store
Artists and content creators can register and freely sell their creations through the Unity store. Game developers can then purchase the content and use within their games.

Unreal Engine Marketplace
Another excellent marketplace. If you use the Unreal Engine then this should be your first port of call for art.



Once you game has been released it is important to collection information about how it is being used. Where are the players getting stumped and giving up, and how do they react to purchase buttons and so on. To do this you need to use an analytics service. Find one that has an API and terms of use that you are comfortable with, and use it. While most are free, others come with fees.
Some of the most popular services used for game only analytics include:

Other widely used analytics tools, for Android apps in general include:


Like the analytics space, there are quite a number of mobile advertising networks. There are different types of ads that can be served, including banners, interstitials, videos, walls, and even ones integrated with in-app purchases. Some networks, for example, deliver excellent interstitials, but do poorly on videos. It is possible to register on multiple ad networks, and serve ads based on which network has the higher rate for a given user location. Some of the major ad networks include

News And Publicity

Of course after writing your game you would want to publicize and share it with the world. These are a collection of websites and blogs that are dedicated to gaming news, trends and information. Most of them are cross platform, not Android only.

Wrap up and Android Developer Newsletter

These are some of the most best and most useful resources available for Android game developers. Now you can get coding, and create the next viral mobile game. Is there any other resource you think should be here? Leave a comment below and share with us.

Do you want to know more? Subscribe to our Android Developer Newsletter. Just type in your email address below to get all the top developer news, tips & links once a week in your inbox:

PS. No spam, ever. Your email address will only ever be used for Android Dev Weekly.

How to use SQLite to store data for your Android app

Posted by wicked April - 29 - 2015 - Wednesday Comments Off

Most Android apps will need to persist user data at sometime. There are different ways to store user data, but SQLite databases are a very convenient and speedy method of saving user (or app) data and information.

SQLite is an opensource SQL database that stores the database as a text file on a device. Basic familiarity with SQL sets up a developer nicely to use Android’s sqlite implementation. And for developers not familiar with SQL, do not be discouraged, SQL is pretty straightforward to learn, use and implement. SQLite is a relational database management system just like Oracle, MySQL and PostgreSQL. Due to its small footprint and public domain license, it is possibly the most widely deployed database engine in the world, it can be found in all types of software ranging from embedded systems, browsers, and operating systems.

Android has a built in SQLite implementation, and application specific database files are stored in a private disk space that’s inaccessible to other applications. This way, no application can access another application’s data.


The complete source code for this tutorial is available on GitHub.

The sample application for this tutorial shows how to create a database, named “SQLiteExample.db”, that contains a single table named “person”. This table stores Person data, including his name, gender and age.

There are two Activities, MainActivity, which shows a list of stored Person names, and CreateOrEditActivity, which allows adding and editing Person details.

The most important class, in our sample, is the ExampleDBHelper class, which extends SQLiteOpenHelper. SQLiteOpenHelper is a helper class designed to manage database creation and version management. You override onCreate() and onUpgrade() methods, and whenever a new database is created or upgraded, the appropriate method gets invoked.

ExampleDBHelper is where all the SQLite operations are carried out, and both MainActivity and CreateOrEditActivity call methods from this class to view, create, update or delete data from the database.

Extending “SQLiteOpenHelper”

We create a class, called ExampleDBHelper, that extends SQLiteOpenHelper. We begin by defining the database, tables and columns as constants. This is always a good idea. If any of these names get changed, rather than hunting through the source for all occurrences, we simply change it once. Take special notice of the column called “_id” (PERSON_COLUMN_ID). This column has special significance which will be discussed below.

public static final String DATABASE_NAME = "SQLiteExample.db";
private static final int DATABASE_VERSION = 1;
public static final String PERSON_TABLE_NAME = "person";
public static final String PERSON_COLUMN_ID = "_id";
public static final String PERSON_COLUMN_NAME = "name";
public static final String PERSON_COLUMN_GENDER = "gender";
public static final String PERSON_COLUMN_AGE = "age";

In the constructor, we call SQLiteOpenHelper’s constructor, passing it the application context, the database name, an SQLiteDatabase.CursorFactory (we actually pass a null object here), and the database version. This constructor handles the creation or upgrade of the database. The database version should begin from 1, and increase linearly, whenever you modify the database schema.

public ExampleDBHelper(Context context) {
    super(context, DATABASE_NAME , null, DATABASE_VERSION);

The onCreate() is called whenever a new database is created. Here, you specify each table schema. In our example app, we have only one table.

public void onCreate(SQLiteDatabase db) {
    db.execSQL("CREATE TABLE " + PERSON_TABLE_NAME + "(" +
        PERSON_COLUMN_NAME + " TEXT, " +

The overridden onUpgrade() method is called whenever the database needs to be upgraded (i.e. when the version has changed). Here, you should drop and/or add tables, or migrate data to new tables, or whatever else needs to be done to move from the previous database schema to the new schema. In our example, we simply drop the existing “person” table, and then call onCreate() to recreate it. I doubt you would want to do this with real user data.

public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

For the sample application, we want the ExampleDBHelper class to handle all data insertion, deletion, updates and views (basically all queries to the database must be through ExampleDBHelper). So we define appropriate methods for each of these scenarios.

To insert a new Person, we use the creatively named insertPerson() method. We use the SQLiteOpenHelper method getWritableDatabase() to get an SQLiteDatabase object reference to our already created database. The Person details are stored in a ContentValues object, with the appropriate column name as key, and corresponding data as value. We then call SQLiteDatabase’s insert method with the person table name, and the ContentValues object. NOTE that we left out the PERSON_COLUMN_ID column, which was specified as a primary key. It automatically increments.

public boolean insertPerson(String name, String gender, int age) {
    SQLiteDatabase db = getWritableDatabase();
    ContentValues contentValues = new ContentValues();
    contentValues.put(PERSON_COLUMN_NAME, name);
    contentValues.put(PERSON_COLUMN_GENDER, gender);
    contentValues.put(PERSON_COLUMN_AGE, age);
    db.insert(PERSON_TABLE_NAME, null, contentValues);
    return true;

To update a person, we created an updatePerson() method. It is similar to the createPerson() method. The equivalent SQL statement to update a person row would be “UPDATE person SET name=’name’ and gender=’gender’ and age=’age’ WHERE ID=’id’“. The SQLiteDatabase update method is a convenient method for updating rows in a table. It is defined as: public int update (String table, ContentValues values, String whereClause, String[] whereArgs), where the whereClause represents the optional where clause, and whereArgs is a String[] of values that would replace the “?’s” included in the whereClause. Passing a null value as the whereClause will update all rows.

public boolean updatePerson(Integer id, String name, String gender, int age) {
    SQLiteDatabase db = this.getWritableDatabase();
    ContentValues contentValues = new ContentValues();
    contentValues.put(PERSON_COLUMN_NAME, name);
    contentValues.put(PERSON_COLUMN_GENDER, gender);
    contentValues.put(PERSON_COLUMN_AGE, age);
    db.update(PERSON_TABLE_NAME, contentValues, PERSON_COLUMN_ID + " = ? ", new String[] { Integer.toString(id) } );
    return true;

We implemented two methods to view person’s in the database. The first retrieves a single person, given his id, and the other retrieves all persons. Since we are not writing to the database, we retrieve a readable database with getReadableDatabase(), and perform a rawQuery(). RawQuery takes a SQL query string, with optional queryArgs and returns a Cursor object. A Cursor provides access to the result set returned. A Cursor can be transversed forward, backwards or randomly. Cursor also provides methods to retrieve particular columns, total columns, total rows and much much more.

public Cursor getPerson(int id) {
    SQLiteDatabase db = this.getReadableDatabase();
    Cursor res = db.rawQuery( "SELECT * FROM " + PERSON_TABLE_NAME + " WHERE " +
        PERSON_COLUMN_ID + "=?", new String[] { Integer.toString(id) } );
    return res;
public Cursor getAllPersons() {
    SQLiteDatabase db = this.getReadableDatabase();
    Cursor res = db.rawQuery( "SELECT * FROM " + PERSON_TABLE_NAME, null );
    return res;

Deleting data is also pretty straightforward. SQLiteDatabase has a delete() method that takes the table name to delete from, and optional whereClause and whereArgs. NOTE: Be very careful when writing this, as passing null in the whereClause would delete all rows.

public Integer deletePerson(Integer id) {
    SQLiteDatabase db = this.getWritableDatabase();
    return db.delete(PERSON_TABLE_NAME,
        PERSON_COLUMN_ID + " = ? ",
        new String[] { Integer.toString(id) });


Integrating the “Helper” with the rest of the app

At this point, we have completely prepared our database for use. To integrate this with both our activities, we initialize ExampleDBHelper in each Activity onCreate() method, and then call the appropriate method, depending on what action is required.

In MainActivity, we display a list of all persons using a ListView. Clicking on the “Add New” button starts CreateOrEditActivity in create mode, allowing us to create a new person. While clicking on any list item starts CreateOrEditActivity in edit mode, allowing us delete or edit and update the person info.

To display the list of persons, we request a Cursor containing all person records. We then use a SimpleCursorAdapter instance for displaying the list items. Do you remember the special column named “_id” mentioned above? SimpleCursorAdapter requires this column, or else it would not work. To use the SimpleCursorAdapter, we define a layout view for each list item called person_info.xml.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android=""




All the magic in MainActivity happens in the onCreate() method. We get a dbHelper object, request for all person’s, and populate the ListView with the received Cursor. Finally, we implement the onItemClickListener() so that when a person is clicked, we get the person ID and parse it as an extra to CreateOrEditActivity.
The complete MainActivity code follows:

public class MainActivity extends ActionBarActivity {
    public final static String KEY_EXTRA_CONTACT_ID = "KEY_EXTRA_CONTACT_ID";

    private ListView listView;
    ExampleDBHelper dbHelper;

    protected void onCreate(Bundle savedInstanceState) {

        Button button = (Button) findViewById(;
        button.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                Intent intent = new Intent(MainActivity.this, CreateOrEditActivity.class);
                intent.putExtra(KEY_EXTRA_CONTACT_ID, 0);

        dbHelper = new ExampleDBHelper(this);

        final Cursor cursor = dbHelper.getAllPersons();
        String [] columns = new String[] {
        int [] widgets = new int[] {

        SimpleCursorAdapter cursorAdapter = new SimpleCursorAdapter(this, R.layout.person_info,
                cursor, columns, widgets, 0);
        listView = (ListView)findViewById(;
        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

            public void onItemClick(AdapterView listView, View view,
                                    int position, long id) {
                Cursor itemCursor = (Cursor) MainActivity.this.listView.getItemAtPosition(position);
                int personID = itemCursor.getInt(itemCursor.getColumnIndex(ExampleDBHelper.PERSON_COLUMN_ID));
                Intent intent = new Intent(getApplicationContext(), CreateOrEditActivity.class);
                intent.putExtra(KEY_EXTRA_CONTACT_ID, personID);



CreateOrEditActivity is a little bit more involved. The Activity allows creating, editing and deleting persons. It also changes its UI based on what action is to be performed. Because of it’s length, we shall only show and discuss the parts relevant to database interaction.

In onCreate(), if we receive a personID, we call dbHelper.getPerson() with that ID, and then populate the fields with the person details:

Cursor rs = dbHelper.getPerson(personID);
            String personName = rs.getString(rs.getColumnIndex(ExampleDBHelper.PERSON_COLUMN_NAME));
            String personGender = rs.getString(rs.getColumnIndex(ExampleDBHelper.PERSON_COLUMN_GENDER));
            int personAge = rs.getInt(rs.getColumnIndex(ExampleDBHelper.PERSON_COLUMN_AGE));
            if (!rs.isClosed()) {

If the delete button is clicked, we call dbHelper.delete() with the personID

                AlertDialog.Builder builder = new AlertDialog.Builder(this);
                        .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {
                                Toast.makeText(getApplicationContext(), "Deleted Successfully", Toast.LENGTH_SHORT).show();
                                Intent intent = new Intent(getApplicationContext(), MainActivity.class);
                        .setNegativeButton(, new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {
                                // User cancelled the dialog
                AlertDialog d = builder.create();
                d.setTitle("Delete Person?");

Finally, we implemented a persistPerson() method that checks if we require a person creation or update.

    public void persistPerson() {
        if(personID > 0) {
            if(dbHelper.updatePerson(personID, nameEditText.getText().toString(),
                    Integer.parseInt(ageEditText.getText().toString()))) {
                Toast.makeText(getApplicationContext(), "Person Update Successful", Toast.LENGTH_SHORT).show();
                Intent intent = new Intent(getApplicationContext(), MainActivity.class);
            else {
                Toast.makeText(getApplicationContext(), "Person Update Failed", Toast.LENGTH_SHORT).show();
        else {
                    Integer.parseInt(ageEditText.getText().toString()))) {
                Toast.makeText(getApplicationContext(), "Person Inserted", Toast.LENGTH_SHORT).show();
                Toast.makeText(getApplicationContext(), "Could not Insert person", Toast.LENGTH_SHORT).show();
            Intent intent = new Intent(getApplicationContext(), MainActivity.class);


Extending SQliteOpenHelper helps you abstract the database creation, updates and maintenance, so you can focus on interacting with the database. We used different methods to interact with the database, including helper methods, and plain SQL commands.

While this sample app creates a simple one-table database, SQLite is a complete relational database system, and supports more advanced features including multiple tables, foreign keys, complex queries with joins and more. Using SQLite in your android app is a fast, secure, efficient and easy way to persist user and app data.

The complete source code for this tutorial is available on GitHub.

Android Developer Newsletter

Do you want to know more? Subscribe to our Android Developer Newsletter. Just type in your email address below to get all the top developer news, tips & links once a week in your inbox:

PS. No spam, ever. Your email address will only ever be used for Android Dev Weekly.

Android customization – how to make a screen recording, using ADB – root not required

Posted by wicked April - 9 - 2015 - Thursday Comments Off

Last week on our Android customization series, we dove into a deep and involved developer tool called ADB, or Android Debug Bridge. Our purpose last week was pretty simple, we were trying to hunt down apps that were eating up the battery on our Android devices, and we used logcat to do so.

This week, now that you’ve got ADB up and rolling, let’s keep using it. I have a short list of tasks I want to perform with ADB, but we will start off with the most fun of them all, capturing a screen recording on your Android device.

Before we get started

You do not require any special apps or to have root on your device to follow along today, or for any of our upcoming ADB tasks in the coming weeks. You will, however, need to have a connected computer with ADB setup and ready to roll.

Nexus 9 HP Chromebook USB ADB logcat

You will need to at least follow along our previous project to see how ADB is setup and enabled on your connected computer, and be ready to connect with an appropriate USB cable for your Android device.

Warning: The screen record functionality in ADB is for video only, it does not capture the audio of your device, please be prepared to capture audio separately, if required. The recording is limited to about 3 minutes in length, to help prevent copyright violations, I presume. Screen rotation is not supported, pick an orientation and stick with it for the recording.

Capture a screen recording with ADB

First things first, connect your Android device to your PC. Follow any steps required to enable ADB, fire up your command/Terminal window and get ready to rock.

ADB screenrecord sample

In your command or Terminal window, enter adb devices and hit enter.

As mentioned last week, you do not really need to do this, but it is always nice to see that your device is connected and reporting to your computer properly.

Now, enter adb shell and hit enter.

Shell enables a subset of new tools within ADB, and, in a manner of speaking, provides access to the command line controls of your actual device. If that does not make sense, don’t worry about it, we’ll have the chance to explain in more detail at a later date.

Enter screenrecord /sdcard/video.mp4 and hit enter.

You are now recording your Android device display.

To stop the recording, wait for three minutes to expire, or simply press Ctrl+C into the command/Terminal window.

ADB screenrecord Moto G on Chromebook

The video file is saved to your Android device, and will be located where you specified above, which would be on your /sdcard/ if you entered the exact text above. Feel free to specify a new storage location on your device, and a new file name as well, be careful not to run the command again right away, as it may overwrite your previous video.mp4 file.

What’s next

Our implementation above utilizes the bare bones defaults of the screen record tool. There are additional options available that may be of use to you.

First, the default will record the video at your device’s screen resolution, if supported. If you have issues, try specifying a specific screen resolution. The general format is to add –size WIDTHxHEIGHT to your command. For example, screenrecord –size 1280×720 /sdcard/recordings/my720pvideo.mp4. Consult your manufacturer for supported resolutions on your Android device’s AVC encoder.

You can also control the bit-rate and recording time (up to 3 minutes.) Head on over to the ADB help pages for more details – fair warning, our next few Android customization posts will cover our favorite tools on that ADB page, feel free to jump ahead if you wish. For now, the following image has the few supported screen record options for you.

ADB screenshots command options

Next week

Now that you have a screen recording or two saved to your Android device, you may want to get it off the device and onto your computer. We have talked about file transfers before on our Android customization series, but we’ve got ADB at our disposal now, so let’s use it. Next week, we will use ADB to transfer files to and from your computer and Android device.

What do you use a screen recording for? Work, entertainment, send to a friend to show them a problem you are having?

Android customization – improve battery life, use ADB logcat to find battery hogs

Posted by wicked April - 2 - 2015 - Thursday Comments Off

Nexus 9 HP Chromebook USB ADB logcat

Last week on our Android customization series, we took a few moments to look at the built-in Android tools in an attempt to hunt down rogue apps eating up your battery. We continue that pursuit for battery life perfection this week, taking a little bit more advanced look at identifying battery killing apps.

Warning: This week’s post is not intended for beginning Android users. While we encourage you all to expand your abilities, maybe even to give this project a go, we will be using Google’s ADB developer tools, which are not exactly made for your everyday Android experience.

Before we get started

Today we have a whole bunch of requirements, luckily, there is a great chance that you have everything you need kicking around. First, you will need a computer with a functioning Windows, Mac or Linux operating system. From there, that computer must have a functioning USB port. Doesn’t sound too bad so far, does it? Lastly, as far as hardware goes, you’ll need the USB cable that goes to your Android device.

Aside from the super obvious stuff above, you are going to need to have the Android SDK and appropriate drivers for your Android device installed on your computer. If you are unsure how this is done, rest assured, we’ve got you covered:

How to install the Android SDK
How to setup ADB

Use Logcat to watch your system

The idea is pretty simple here today folks, logcat is a tool that watches all of the system level actions on your device. While this list may be a little overwhelming at first, it is a low level developer’s tool after all, it shouldn’t take long for you to recognize your apps and how they are taking up the cycles on your device.

Once you have the Android SDK and ADP setup and running, you are likely already connected to your computer, but let’s start with those steps anyhow.

Nexus 9 HP Chromebook USB cable

Connect your Android device to your computer.

Turn on the necessary settings for your device, including USB Debugging, which is found in your Developer Options.

Fire up a command prompt on your computer.

Now, you will either have to CD (change directory) navigate to the location of your ADB.exe, or, find it in your platform-tools folder and open the folder in a terminal/command window.

Enter the command adb devices and hit enter. This step isn’t actually required, but it is a simple way to make sure your PC and your Android device are talking.

Enter the command adb logcat and hit enter.

Sit back and watch as your device pumps out its actions to your computer screen.

ADB Logcat CMD Windows

Now that you have your logcat, what’s eating your battery?

There is no easy solution here. Logcat is designed to catch actions as they happen, this means you will need to spend some time connected, allowing your device to do its thing. As you watch the log, you will soon begin to identify your apps, especially if they are misbehaving.

Our results

ADB Logcat Pogoplug WiFi off

If you recall, we’ve been hunting down poor battery life on our Nexus 9. Although we still have to figure out the real culprit, we learned something extremely valuable. We were able to determine that, as anticipated, two of our favorite customization apps, Pushbullet and Zooper Widget, are very well behaved apps. They do keep the device awake a bit here and there, as is expected with this level of use, but certainly are well behaved enough that uninstalling them is not required. At least this is true when you are connected to WiFi!

That’s right, the moment we turned off WiFi, as we have been doing frequently in an attempt to reduce power consumption, activity for both services ramp up. Again, the actions Pushbullet and Zooper Widget are taking are not strenuous on the battery themselves, but they are frequent, preventing your device from entering and remaining in a sleep state, thus, killing the battery faster than would be expected. Do we uninstall the apps or just keep WiFi turned on? Not sure yet, but we are pleased that we have something to work with.

What’s next

I hope that you were not expecting magic here today folks. There is no doubt that logcat is a bulletproof method to see what your device is doing in the background, but it is now up to you to determine if all of your apps’ actions are justified, or if you need to do a little uninstalling.

Every once in a while you can repair an app without full un-installation. Make sure you’ve got the app data backed up, if applicable, then head into the App section of Settings, try hitting the Clear Cache and/or Clear Data buttons. Clearing data will reset the app to an empty state, wiping all of your saved game data or requiring you to log back into the service.

Android clear app cache

While there is no guarantee that wiping an app’s data will fix it, you should find it is at least worth trying before giving up and uninstalling completely.

Final thought, do keep in mind that there are some apps that you just cannot fix. We’ve named and shamed some of these apps before. In the end, you may choose to live with the battery drain, if the app serves a purpose well enough for you. Worst of all, you may find that the Android operating system itself is sapping all your juice. If you are like me, you are just sitting back praying that Google pushes out a fix soon, or are considering some of those custom ROMs out there instead.

Next week

Android ADB shell

As we continued the process of hunting down apps that are eating up our battery, our Android customization post this week took to logcat to see what is going on. To get to logcat, we needed to use ADB, and you know what, ADB has some other cool features as well, let’s take a look at a few next week.

Did you manage to find any rogue apps in your logcat today? Will you uninstall them? Can you uninstall them?

Google getting serious with Cardboard

Posted by wicked December - 11 - 2014 - Thursday Comments Off


Whatever it started as, Google’s virtual reality viewer originally released as a “device” made out of a cardboard box has proven so successful that Google is investing even more in the platform. According to Google, they count more than half a million Cardboard viewers in use and with numbers like that, they have released a new round of updates for users, developers and makers of the device.

For users looking for a Cardboard compatible app, Google is making things a little easier with a dedicated collection page in the Google Play Store just for Cardboard apps. There are a variety out there including test drives, concerts, even games.

Developers who want to try their hand at a VR application now have access to a new set of Cardboard SDKs for Android and Unity. Google says the SDKs will speed the development process by taking over things like lens distortion correction, head tracking and side-by-side rendering. That will allow developers to focus on things like gameplay or graphics.

Google also announced the release of updated specifications for the open source Cardboard viewer. The primary addition to this update is specs for specific cutting tools that will help producers more easily do things like laser- or die-cut their viewers, even in large quantities. However, users who want a DIY solution can still use the specs for their own device.

Google indicated that next year they plan to add a calibration tool to the Cardboard SDK. This means things like the base and focal length for different viewers can be defined and apps will automatically adjust.

Anyone out there using Google Cardboard?

source: Google Developers

Come comment on this article: Google getting serious with Cardboard

ePad 7 Android 4.0 ICS
$162 $100 FREE SHIPPING 

10" Android 4.2 1.2GHz Tablet PC