HELP...WHy I cannnot insert value to a specific column?
public class WorkDetailsTable extends Activity{
private SQLiteDatabase database;
private MyDatabaseHelper dbHelper;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tableworkdetails);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
dbHelper = new MyDatabaseHelper(this);
database = dbHelper.getWritableDatabase();
Button btn1=(Button)findViewById(R.id.button2);
btn1.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
AlertDialog.Builder builder=new AlertDialog.Builder(WorkDetailsTable.this);
builder.setTitle("Data Saved");
builder.setMessage("Are you sure you want to save?");
builder.setIcon(android.R.drawable.ic_dialog_alert);
builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int ii) {
W4 = txtWork4.getText().toString();
a4 = spinnerTra4.getSelectedItem().toString();
P4 = per4.getText().toString();
if ((TextUtils.isEmpty(W4)) && (TextUtils.isEmpty(P4)) && (TextUtils.isEmpty(h)) && (TextUtils.isEmpty(i))) {
Toast.makeText(getApplicationContext(), "Row 4 is empty", Toast.LENGTH_LONG).show();
}
else if ((!(TextUtils.isEmpty(W4)))||(!(TextUtils.isEmpty(P4)))||(!(TextUtils.isEmpty(h)))||((TextUtils.isEmpty(i)))) {
WD.insertWorkDetails(a4, W4, P4, h,i);
}
else if ((!(TextUtils.isEmpty(W4)))||(!(TextUtils.isEmpty(P4)))||(!(TextUtils.isEmpty(h)))||(!(TextUtils.isEmpty(i))))
{
WD.insertWorkDetails(a4, W4, P4, h, i);
database = dbHelper.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(MyDatabaseHelper.TimeOut_Info, i);
database.insert(MyDatabaseHelper.TABLE_INFO, null, values);
Toast.makeText(getApplicationContext(), "Done", Toast.LENGTH_LONG).show();
}
checkRow3(W3, P3, f, g);// check row 3;
checkRow2(W2, P2, d, e1);//check row 2;
checkRow1(W1, P1, b, c);
In my if-else condition, I have set if ((!(TextUtils.isEmpty(W4)))||(!(TextUtils.isEmpty(P4)))||(!(TextUtils.isEmpty(h)))||(!(TextUtils.isEmpty(i)))), then they will insert into SQLite and value i will be inserted into selected column from another table. In my SQLite, I can see value W4,P4,h,i inserted into the table, but value i does not insert into the selected column from another table..Why could this happen? How can I fix this?
Is the error came form here?
private SQLiteDatabase database;
private MyDatabaseHelper dbHelper;
dbHelper = new MyDatabaseHelper(this);
database = dbHelper.getWritableDatabase();
Aucun commentaire:
Enregistrer un commentaire