Friday, 20 April 2012

Create DataBase In Android (Part 2)

Step 1:- Now create Insert Method in database class for inserting data in database table

public long insert(String title,String type) {

return this.insertStmt.executeInsert();

Step 2:- Now Create Select Method

     public void selectAll() {
Cursor cursor = null;
    cursor = this.db.query(TABLE_NAME, new String[] { "title","type"},
"", null, null, null, "id desc");
if (cursor.moveToFirst()) {

do {

} while (cursor.moveToNext());
if (cursor != null && !cursor.isClosed()) {

Setp 3: - Method for delete and Update Table Data

public void deleteAll() {
this.db.delete(TABLE_NAME, null, null);

public void deleteRow(long rowId) {
db.delete(TABLE_NAME, "id=" + rowId, null);

public void updateRow(long rowId, String text, String title, String date) {
ContentValues args = new ContentValues();
args.put("memodata", text);
args.put("title", title);
db.update(TABLE_NAME, args, "id=" + rowId, null);

Create DataBase In Android (Part 1)

Setp by Step Procedure for Create Database in android :-

Setp 1:- Create a new Class Database first

public class Database{
          public Database(Context context)

Setp 2:- Create  static class in Database class which extend SQLiteOpenHelper same as below

private static class OpenHelper extends SQLiteOpenHelper {
OpenHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
public void onCreate(SQLiteDatabase db) {
+ "          (id INTEGER PRIMARY KEY,title TEXT, type TEXT)");

public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
"Upgrading database, this will drop tables and recreate.");


Step 3:- Now create below object in Database Class

        private static final String DATABASE_NAME = "DBName.db";
private static final int DATABASE_VERSION = 1;
private static final String TABLE_NAME="DBNAME" ;
private Context context;
private SQLiteDatabase db;
private SQLiteStatement insertStmt;
private String INSERT="insert into " + TABLE_NAME + " (title,type) values (?,?)";

Step 4:- Initialize object in Database class constructor 

      public Database(Context context) {
this.context = context;
OpenHelper openHelper = new OpenHelper(this.context);
this.db = openHelper.getWritableDatabase();
this.insertStmt = this.db.compileStatement(INSERT);

Bitmap Object for Resource Image in android

Bitmap bitmap;
bitmap=BitmapFactory.decodeResource( context.getResources(), R.drawable.MyImage);

Thursday, 19 April 2012

Email, SMS and Facebook Integration in Android App

* If you want to send email, sms or post any comments on Facebook then below i show code which we can use for send email, sms and post any comments on facebook with image and text *

Intent sharingIntent = new Intent(Intent.ACTION_SEND);
Uri screenshotUri = Uri.parse("android.resource://com.hanuma/" + R.drawable.front);
sharingIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri);
sharingIntent.putExtra(Intent.EXTRA_TITLE, "Your Title Text");
sharingIntent.putExtra(Intent.EXTRA_TEXT,"Other Text");
context.startActivity(Intent.createChooser(sharingIntent, "Send"));

Read Resource Contain using URI

Uri of Resource Contain:-
Uri uri=Uri.parse("android.resource://com.androidbook.samplevideo/" + R.raw.myvideo);

Tuesday, 17 April 2012

Alert Message Box in Android

*Show Alart Message Box in Android *

AlertDialog.Builder adb=new AlertDialog.Builder(activity);

    adb.setMessage("Do you want to delete Note.");
    adb.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
           public void onClick(DialogInterface dialog, int id) {
            System.out.println("zdfsdfksjDfjkds:hi me hi me  ";
    adb.setNegativeButton("No", null);;

What is Android

Android is a Linux-based operating system for mobile devices such as smartphones and tablet computers. It is developed by the Open Handset Alliance led by Google.
Google purchased the initial developer of the software, Android Inc., in 2005. The unveiling of the Android distribution in 2007 was announced with the founding of the Open Handset Alliance, a consortium of 86 hardware, software, and telecommunication companies devoted to advancing open standards for mobile devices. Google releases the Android code as open-source, under the Apache License. The Android Open Source Project (AOSP) is tasked with the maintenance and further development of Android.
Android has a large community of developers writing applications ("apps") that extend the functionality of the devices. Developers write primarily in a customized version of Java. Apps can be downloaded from third-party sites or through online stores such as Google Play (formerly Android Market), the app store run by Google. As of February 2012 there were more than 450,000 apps available for Android, and the estimated number of applications downloaded from the Android Market as of December 2011 exceeded 10 billion.