Hi, I want to create two different tables in a database. These User_details and Creditcard_details tables I created the following DBAdapter class to implement database operations, however, when I call the insertCreditcard () method, the values are not inserted. I wonder if a second table is being created. I’m mistaken, but I can’t understand where and what should I do to fix the problem.
What I was exactly trying to do was check the id field from the User_details table against the username and password provided during login activity, and then assign the value of this id variable to another variable called ccid , which is used to search for rows in the Creditcard_details table or insert into her meanings.
Can anybody help me.
package com.androidbook.LoginForm; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.SQLException; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.util.Log; import android.widget.Toast; public class DBAdapter { public static Cursor d; public static final String KEY_ROWID = "_id"; public static final String KEY_Name = "name"; public static final String KEY_Username = "username"; public static final String KEY_Password = "password"; private static final String TAG = "DBAdapter"; private static final String DATABASE_NAME = "Wallet"; private static final String DATABASE_TABLE = "User_Details"; private static final String KEY_CCID = "_ccid"; private static final String KEY_CCUNAME= "cuname"; private static final String KEY_CCNO = "ccno"; private static final String KEY_CVV = "cvvno"; private static final String EXP_DATE = "expdate"; private static final String CREDITCARDS_TABLE = "Creditcard_Details"; private static final int DATABASE_VERSION = 1; private static final String DATABASE_CREATE = "create table User_Details (_id integer primary key autoincrement, " + "name text not null, username text not null, " + "password text not null);"; private static final String CCTABLE_CREATE = "create table Creditcard_Details ( _ccid integer primary key , " + "cuname text not null, ccno text not null, " + "cvvno text not null" + "expdate text not null )";
source share