i have Created a database in Sqllite Android Application.and i try to
add two tables in my Database But i have problem to create that
Database.First Table only Created.AnyBody Help me Thanks in Advance!


package com.android.cdtech;

import java.sql.SQLException;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class saveData {
         public static final String KEY_ROWID = "rowid"; public static final
String KEY_DATE = "Date";public static final String KEY_NAME =
"CustomerName";public static final String KEY_AMOUNT = "Amount";public
static final String KEY_BANK = "Banks";
         private static final String TAG = "DBAdapter";
         public static final String KEY_BUSNAME="BusinessName";public static
final String KEY_ADD="Address";public static final String
KEY_CPERSON="ContactPerson";public static final String
KEY_PNUM="PhoneNumber";public static final String KEY_MAIL="EmailID";
         public static final String KEY_TINUMBER="TINNumber";public static
final String KEY_CREDITLIMIT="CreditLimit";public static final String
KEY_CREDITDAYS="CreditDays";
     private static final String DATABASE_NAME = "EXPORTDETAILS";
         private static final String DATABASE_TABLE = "Payment";
         private static final String DATABASE_TABLE2 = "Customer";
         private static final int DATABASE_VERSION = 1;
        // private static final String DATABASE_CREATE =   ;

        // private static final String DATABASE_CREATECUS =
                          // ;
         private final Context context;
         private DatabaseHelper DBHelper;
         private SQLiteDatabase db;



            public saveData(Context ctx)
            {
                this.context = ctx;
                DBHelper = new DatabaseHelper(context);
            }
            private static class DatabaseHelper extends SQLiteOpenHelper
            {
                DatabaseHelper(Context context)
                {
                    super(context, DATABASE_NAME, null, DATABASE_VERSION);
                }

                @Override
                public void onCreate(SQLiteDatabase db)
                {
                         db.execSQL( "create table Customer (_id1 integer 
primary
key autoincrement, "
                                                + "BusinessName text not 
null,"+"Address text not
null,"+"ContactPerson text not null,"+"PhoneNumber text not
null,"+"EmailID text not null,"+"TINNumbertext not null,"+"CreditLimit
text not null,"+"CreditDays text not null);");

                    db.execSQL("create table Payment (_id integer primary key
autoincrement, "
                                + "Date text not null,"+"CustomerName text not
null,"+"Amount text not null,"+"Banks text not null);");
                    }

                @Override
                public void onUpgrade(SQLiteDatabase db, int oldVersion,
                                      int newVersion)
                {
                    Log.w(TAG, "Upgrading database from version " +
oldVersion
                          + " to "
                          + newVersion + ", which will destroy all old
data");
                    db.execSQL("DROP TABLE IF EXISTS titles");
                    onCreate(db);
                }
            }
        public saveData open()throws SQLException
        {
                db=DBHelper.getWritableDatabase();
                return this;
        }
        public void close()
        {
                DBHelper.close();
        }

                public long insert(String Date,String CustomerName,String
Amount,String Banks) {
                // TODO Auto-generated method stub
                 ContentValues cv=new ContentValues();
                 cv.put(KEY_DATE,Date);
                 cv.put(KEY_NAME,CustomerName);
                 cv.put(KEY_AMOUNT,Amount);
                 cv.put(KEY_BANK,Banks);
                 return db.insert(DATABASE_TABLE, null,cv);
        }
                public long insertForm(String BusinessName ,String Address 
,String
ContactPerson,String PhoneNumber,String EmailID,String
TINNumber,String CreditLimit,String CreditDays) {
                        // TODO Auto-generated method stub
                         ContentValues cv=new ContentValues();
                         cv.put(KEY_BUSNAME,BusinessName);
                         cv.put(KEY_ADD,Address);
                         cv.put(KEY_CPERSON,ContactPerson);
                         cv.put(KEY_PNUM,PhoneNumber);
                         cv.put(KEY_MAIL,EmailID);
                         cv.put(KEY_TINUMBER,TINNumber);
                         cv.put(KEY_CREDITLIMIT,CreditLimit);
                         cv.put(KEY_CREDITDAYS,CreditDays);
                         return db.insert(DATABASE_TABLE2, null,cv);
                }
                public Cursor getlatlng()
                 {
                        Cursor latlngCursor = db.rawQuery("select * from " +
DATABASE_TABLE,null);
                         if (latlngCursor != null)
                         {
                                 latlngCursor.moveToFirst();
                         }
                         db.close();
                        return latlngCursor;
                 }
                public Cursor order()
                 {
                        Cursor latlngCursor1 = db.rawQuery("select * from " +
DATABASE_TABLE2,null);
                         if (latlngCursor1 != null)
                         {
                                 latlngCursor1.moveToFirst();
                         }
                         db.close();
                        return latlngCursor1;
                 }
}









-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to