Program: 164523
Project: 164523
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  dbm=new yourCustomSqlLiteHelperclass(AndroidDatabaseManager.this);
  mainscrollview=new ScrollView(AndroidDatabaseManager.this);
  mainLayout=new LinearLayout(AndroidDatabaseManager.this);
  mainLayout.setOrientation(LinearLayout.VERTICAL);
  mainLayout.setBackgroundColor(Color.WHITE);
  mainLayout.setScrollContainer(true);
  mainscrollview.addView(mainLayout);
  setContentView(mainscrollview);
  final LinearLayout firstrow=new LinearLayout(AndroidDatabaseManager.this);
  firstrow.setPadding(0,10,0,20);
  LinearLayout.LayoutParams firstrowlp=new LinearLayout.LayoutParams(0,150);
  firstrowlp.weight=1;
  TextView maintext=new TextView(AndroidDatabaseManager.this);
  maintext.setText("String_Node_Str");
  maintext.setTextSize(22);
  maintext.setLayoutParams(firstrowlp);
  select_table=new Spinner(AndroidDatabaseManager.this);
  select_table.setLayoutParams(firstrowlp);
  firstrow.addView(maintext);
  firstrow.addView(select_table);
  mainLayout.addView(firstrow);
  ArrayList<Cursor> alc;
  hsv=new HorizontalScrollView(AndroidDatabaseManager.this);
  tableLayout=new TableLayout(AndroidDatabaseManager.this);
  tableLayout.setHorizontalScrollBarEnabled(true);
  hsv.addView(tableLayout);
  final LinearLayout secondrow=new LinearLayout(AndroidDatabaseManager.this);
  secondrow.setPadding(0,20,0,10);
  LinearLayout.LayoutParams secondrowlp=new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT);
  secondrowlp.weight=1;
  TextView secondrowtext=new TextView(AndroidDatabaseManager.this);
  secondrowtext.setText("String_Node_Str");
  secondrowtext.setTextSize(20);
  secondrowtext.setLayoutParams(secondrowlp);
  tv=new TextView(AndroidDatabaseManager.this);
  tv.setTextSize(20);
  tv.setLayoutParams(secondrowlp);
  secondrow.addView(secondrowtext);
  secondrow.addView(tv);
  mainLayout.addView(secondrow);
  final EditText customquerytext=new EditText(this);
  customquerytext.setVisibility(View.GONE);
  customquerytext.setHint("String_Node_Str");
  mainLayout.addView(customquerytext);
  final Button submitQuery=new Button(AndroidDatabaseManager.this);
  submitQuery.setVisibility(View.GONE);
  submitQuery.setText("String_Node_Str");
  submitQuery.setBackgroundColor(Color.parseColor("String_Node_Str"));
  mainLayout.addView(submitQuery);
  final TextView help=new TextView(AndroidDatabaseManager.this);
  help.setText("String_Node_Str");
  help.setPadding(0,5,0,5);
  final Spinner spinnertable=new Spinner(AndroidDatabaseManager.this);
  mainLayout.addView(spinnertable);
  mainLayout.addView(help);
  hsv.setPadding(0,10,0,10);
  hsv.setScrollbarFadingEnabled(false);
  hsv.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_INSET);
  mainLayout.addView(hsv);
  final LinearLayout thirdrow=new LinearLayout(AndroidDatabaseManager.this);
  previous=new Button(AndroidDatabaseManager.this);
  previous.setText("String_Node_Str");
  previous.setBackgroundColor(Color.parseColor("String_Node_Str"));
  previous.setLayoutParams(secondrowlp);
  next=new Button(AndroidDatabaseManager.this);
  next.setText("String_Node_Str");
  next.setBackgroundColor(Color.parseColor("String_Node_Str"));
  next.setLayoutParams(secondrowlp);
  TextView tvblank=new TextView(this);
  tvblank.setLayoutParams(secondrowlp);
  thirdrow.setPadding(0,10,0,10);
  thirdrow.addView(previous);
  thirdrow.addView(tvblank);
  thirdrow.addView(next);
  mainLayout.addView(thirdrow);
  tvmessage=new TextView(AndroidDatabaseManager.this);
  tvmessage.setText("String_Node_Str");
  String Query="String_Node_Str";
  tvmessage.setTextSize(18);
  mainLayout.addView(tvmessage);
  final Button customQuery=new Button(AndroidDatabaseManager.this);
  customQuery.setText("String_Node_Str");
  customQuery.setBackgroundColor(Color.parseColor("String_Node_Str"));
  mainLayout.addView(customQuery);
  customQuery.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      indexInfo.isCustomQuery=true;
      secondrow.setVisibility(View.GONE);
      spinnertable.setVisibility(View.GONE);
      help.setVisibility(View.GONE);
      customquerytext.setVisibility(View.VISIBLE);
      submitQuery.setVisibility(View.VISIBLE);
      select_table.setSelection(0);
      customQuery.setVisibility(View.GONE);
    }
  }
);
  submitQuery.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      tableLayout.removeAllViews();
      customQuery.setVisibility(View.GONE);
      ArrayList<Cursor> alc2;
      String Query10=customquerytext.getText().toString();
      Log.d("String_Node_Str",Query10);
      alc2=dbm.getData(Query10);
      final Cursor c4=alc2.get(0);
      Cursor Message2=alc2.get(1);
      Message2.moveToLast();
      if (Message2.getString(0).equalsIgnoreCase("String_Node_Str")) {
        tvmessage.setBackgroundColor(Color.parseColor("String_Node_Str"));
        if (c4 != null) {
          tvmessage.setText("String_Node_Str" + c4.getCount());
          if (c4.getCount() > 0) {
            indexInfo.maincursor=c4;
            refreshTable(1);
          }
        }
 else {
          tvmessage.setText("String_Node_Str");
          refreshTable(1);
        }
      }
 else {
        tvmessage.setBackgroundColor(Color.parseColor("String_Node_Str"));
        tvmessage.setText("String_Node_Str" + Message2.getString(0));
      }
    }
  }
);
  tableRowParams=new TableRow.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
  tableRowParams.setMargins(0,0,2,0);
  alc=dbm.getData(Query);
  final Cursor c=alc.get(0);
  Cursor Message=alc.get(1);
  Message.moveToLast();
  String msg=Message.getString(0);
  Log.d("String_Node_Str",msg);
  ArrayList<String> tablenames=new ArrayList<String>();
  if (c != null) {
    c.moveToFirst();
    tablenames.add("String_Node_Str");
    do {
      tablenames.add(c.getString(0));
    }
 while (c.moveToNext());
  }
  ArrayAdapter<String> tablenamesadapter=new ArrayAdapter<String>(AndroidDatabaseManager.this,android.R.layout.simple_spinner_item,tablenames){
    public View getView(    int position,    View convertView,    ViewGroup parent){
      View v=super.getView(position,convertView,parent);
      v.setBackgroundColor(Color.WHITE);
      TextView adap=(TextView)v;
      adap.setTextSize(20);
      return adap;
    }
    public View getDropDownView(    int position,    View convertView,    ViewGroup parent){
      View v=super.getDropDownView(position,convertView,parent);
      v.setBackgroundColor(Color.WHITE);
      return v;
    }
  }
;
  tablenamesadapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  if (tablenamesadapter != null) {
    select_table.setAdapter(tablenamesadapter);
  }
  select_table.setOnItemSelectedListener(new OnItemSelectedListener(){
    @Override public void onItemSelected(    AdapterView<?> parent,    View view,    int pos,    long id){
      if (pos == 0 && !indexInfo.isCustomQuery) {
        secondrow.setVisibility(View.GONE);
        hsv.setVisibility(View.GONE);
        thirdrow.setVisibility(View.GONE);
        spinnertable.setVisibility(View.GONE);
        help.setVisibility(View.GONE);
        tvmessage.setVisibility(View.GONE);
        customquerytext.setVisibility(View.GONE);
        submitQuery.setVisibility(View.GONE);
        customQuery.setVisibility(View.GONE);
      }
      if (pos != 0) {
        secondrow.setVisibility(View.VISIBLE);
        spinnertable.setVisibility(View.VISIBLE);
        help.setVisibility(View.VISIBLE);
        customquerytext.setVisibility(View.GONE);
        submitQuery.setVisibility(View.GONE);
        customQuery.setVisibility(View.VISIBLE);
        hsv.setVisibility(View.VISIBLE);
        tvmessage.setVisibility(View.VISIBLE);
        thirdrow.setVisibility(View.VISIBLE);
        c.moveToPosition(pos - 1);
        indexInfo.cursorpostion=pos - 1;
        Log.d("String_Node_Str","String_Node_Str" + c.getString(0));
        indexInfo.table_name=c.getString(0);
        tvmessage.setText("String_Node_Str");
        tvmessage.setBackgroundColor(Color.WHITE);
        tableLayout.removeAllViews();
        ArrayList<String> spinnertablevalues=new ArrayList<String>();
        spinnertablevalues.add("String_Node_Str");
        spinnertablevalues.add("String_Node_Str");
        spinnertablevalues.add("String_Node_Str");
        spinnertablevalues.add("String_Node_Str");
        ArrayAdapter<String> spinnerArrayAdapter=new ArrayAdapter<String>(getApplicationContext(),android.R.layout.simple_spinner_dropdown_item,spinnertablevalues);
        spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_item);
        ArrayAdapter<String> adapter=new ArrayAdapter<String>(AndroidDatabaseManager.this,android.R.layout.simple_spinner_item,spinnertablevalues){
          public View getView(          int position,          View convertView,          ViewGroup parent){
            View v=super.getView(position,convertView,parent);
            v.setBackgroundColor(Color.WHITE);
            TextView adap=(TextView)v;
            adap.setTextSize(20);
            return adap;
          }
          public View getDropDownView(          int position,          View convertView,          ViewGroup parent){
            View v=super.getDropDownView(position,convertView,parent);
            v.setBackgroundColor(Color.WHITE);
            return v;
          }
        }
;
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spinnertable.setAdapter(adapter);
        String Query2="String_Node_Str" + c.getString(0);
        Log.d("String_Node_Str","String_Node_Str" + Query2);
        ArrayList<Cursor> alc2=dbm.getData(Query2);
        final Cursor c2=alc2.get(0);
        indexInfo.maincursor=c2;
        if (c2 != null) {
          int counts=c2.getCount();
          indexInfo.isEmpty=false;
          Log.d("String_Node_Str","String_Node_Str" + counts);
          tv.setText("String_Node_Str" + counts);
          spinnertable.setOnItemSelectedListener((new AdapterView.OnItemSelectedListener(){
            @Override public void onItemSelected(            AdapterView<?> parentView,            View selectedItemView,            int position,            long id){
              ((TextView)parentView.getChildAt(0)).setTextColor(Color.rgb(0,0,0));
              if (spinnertable.getSelectedItem().toString().equals("String_Node_Str")) {
                runOnUiThread(new Runnable(){
                  @Override public void run(){
                    if (!isFinishing()) {
                      new AlertDialog.Builder(AndroidDatabaseManager.this).setTitle("String_Node_Str").setMessage("String_Node_Str" + indexInfo.table_name + "String_Node_Str").setPositiveButton("String_Node_Str",new DialogInterface.OnClickListener(){
                        public void onClick(                        DialogInterface dialog,                        int which){
                          String Query6="String_Node_Str" + indexInfo.table_name;
                          ArrayList<Cursor> aldropt=dbm.getData(Query6);
                          Cursor tempc=aldropt.get(1);
                          tempc.moveToLast();
                          Log.d("String_Node_Str",tempc.getString(0));
                          if (tempc.getString(0).equalsIgnoreCase("String_Node_Str")) {
                            tvmessage.setBackgroundColor(Color.parseColor("String_Node_Str"));
                            tvmessage.setText(indexInfo.table_name + "String_Node_Str");
                            refreshactivity();
                          }
 else {
                            tvmessage.setBackgroundColor(Color.parseColor("String_Node_Str"));
                            tvmessage.setText("String_Node_Str" + tempc.getString(0));
                            spinnertable.setSelection(0);
                          }
                        }
                      }
).setNegativeButton("String_Node_Str",new DialogInterface.OnClickListener(){
                        public void onClick(                        DialogInterface dialog,                        int which){
                          spinnertable.setSelection(0);
                        }
                      }
).create().show();
                    }
                  }
                }
);
              }
              if (spinnertable.getSelectedItem().toString().equals("String_Node_Str")) {
                runOnUiThread(new Runnable(){
                  @Override public void run(){
                    if (!isFinishing()) {
                      new AlertDialog.Builder(AndroidDatabaseManager.this).setTitle("String_Node_Str").setMessage("String_Node_Str" + indexInfo.table_name + "String_Node_Str").setPositiveButton("String_Node_Str",new DialogInterface.OnClickListener(){
                        public void onClick(                        DialogInterface dialog,                        int which){
                          String Query7="String_Node_Str" + indexInfo.table_name;
                          Log.d("String_Node_Str",Query7);
                          ArrayList<Cursor> aldeletet=dbm.getData(Query7);
                          Cursor tempc=aldeletet.get(1);
                          tempc.moveToLast();
                          Log.d("String_Node_Str",tempc.getString(0));
                          if (tempc.getString(0).equalsIgnoreCase("String_Node_Str")) {
                            tvmessage.setBackgroundColor(Color.parseColor("String_Node_Str"));
                            tvmessage.setText(indexInfo.table_name + "String_Node_Str");
                            indexInfo.isEmpty=true;
                            refreshTable(0);
                          }
 else {
                            tvmessage.setBackgroundColor(Color.parseColor("String_Node_Str"));
                            tvmessage.setText("String_Node_Str" + tempc.getString(0));
                            spinnertable.setSelection(0);
                          }
                        }
                      }
).setNegativeButton("String_Node_Str",new DialogInterface.OnClickListener(){
                        public void onClick(                        DialogInterface dialog,                        int which){
                          spinnertable.setSelection(0);
                        }
                      }
).create().show();
                    }
                  }
                }
);
              }
              if (spinnertable.getSelectedItem().toString().equals("String_Node_Str")) {
                final LinkedList<TextView> addnewrownames=new LinkedList<TextView>();
                final LinkedList<EditText> addnewrowvalues=new LinkedList<EditText>();
                final ScrollView addrowsv=new ScrollView(AndroidDatabaseManager.this);
                Cursor c4=indexInfo.maincursor;
                if (indexInfo.isEmpty) {
                  getcolumnnames();
                  for (int i=0; i < indexInfo.emptytablecolumnnames.size(); i++) {
                    String cname=indexInfo.emptytablecolumnnames.get(i);
                    TextView tv=new TextView(getApplicationContext());
                    tv.setText(cname);
                    addnewrownames.add(tv);
                  }
                  for (int i=0; i < addnewrownames.size(); i++) {
                    EditText et=new EditText(getApplicationContext());
                    addnewrowvalues.add(et);
                  }
                }
 else {
                  for (int i=0; i < c4.getColumnCount(); i++) {
                    String cname=c4.getColumnName(i);
                    TextView tv=new TextView(getApplicationContext());
                    tv.setText(cname);
                    addnewrownames.add(tv);
                  }
                  for (int i=0; i < addnewrownames.size(); i++) {
                    EditText et=new EditText(getApplicationContext());
                    addnewrowvalues.add(et);
                  }
                }
                final RelativeLayout addnewlayout=new RelativeLayout(AndroidDatabaseManager.this);
                RelativeLayout.LayoutParams addnewparams=new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
                addnewparams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
                for (int i=0; i < addnewrownames.size(); i++) {
                  TextView tv=addnewrownames.get(i);
                  EditText et=addnewrowvalues.get(i);
                  int t=i + 400;
                  int k=i + 500;
                  int lid=i + 600;
                  tv.setId(t);
                  tv.setTextColor(Color.parseColor("String_Node_Str"));
                  et.setBackgroundColor(Color.parseColor("String_Node_Str"));
                  et.setTextColor(Color.parseColor("String_Node_Str"));
                  et.setId(k);
                  final LinearLayout ll=new LinearLayout(AndroidDatabaseManager.this);
                  LinearLayout.LayoutParams tvl=new LinearLayout.LayoutParams(0,100);
                  tvl.weight=1;
                  ll.addView(tv,tvl);
                  ll.addView(et,tvl);
                  ll.setId(lid);
                  Log.d("String_Node_Str","String_Node_Str" + et.getText().toString());
                  RelativeLayout.LayoutParams rll=new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
                  rll.addRule(RelativeLayout.BELOW,ll.getId() - 1);
                  rll.setMargins(0,20,0,0);
                  addnewlayout.addView(ll,rll);
                }
                addnewlayout.setBackgroundColor(Color.WHITE);
                addrowsv.addView(addnewlayout);
                Log.d("String_Node_Str","String_Node_Str");
                runOnUiThread(new Runnable(){
                  @Override public void run(){
                    if (!isFinishing()) {
                      new AlertDialog.Builder(AndroidDatabaseManager.this).setTitle("String_Node_Str").setCancelable(false).setView(addrowsv).setPositiveButton("String_Node_Str",new DialogInterface.OnClickListener(){
                        public void onClick(                        DialogInterface dialog,                        int which){
                          indexInfo.index=10;
                          String Query4="String_Node_Str" + indexInfo.table_name + "String_Node_Str";
                          for (int i=0; i < addnewrownames.size(); i++) {
                            TextView tv=addnewrownames.get(i);
                            tv.getText().toString();
                            if (i == addnewrownames.size() - 1) {
                              Query4=Query4 + tv.getText().toString();
                            }
 else {
                              Query4=Query4 + tv.getText().toString() + "String_Node_Str";
                            }
                          }
                          Query4=Query4 + "String_Node_Str";
                          for (int i=0; i < addnewrownames.size(); i++) {
                            EditText et=addnewrowvalues.get(i);
                            et.getText().toString();
                            if (i == addnewrownames.size() - 1) {
                              Query4=Query4 + "String_Node_Str" + et.getText().toString()+ "String_Node_Str";
                            }
 else {
                              Query4=Query4 + "String_Node_Str" + et.getText().toString()+ "String_Node_Str";
                            }
                          }
                          Log.d("String_Node_Str",Query4);
                          ArrayList<Cursor> altc=dbm.getData(Query4);
                          Cursor tempc=altc.get(1);
                          tempc.moveToLast();
                          Log.d("String_Node_Str",tempc.getString(0));
                          if (tempc.getString(0).equalsIgnoreCase("String_Node_Str")) {
                            tvmessage.setBackgroundColor(Color.parseColor("String_Node_Str"));
                            tvmessage.setText("String_Node_Str" + indexInfo.table_name);
                            refreshTable(0);
                          }
 else {
                            tvmessage.setBackgroundColor(Color.parseColor("String_Node_Str"));
                            tvmessage.setText("String_Node_Str" + tempc.getString(0));
                            spinnertable.setSelection(0);
                          }
                        }
                      }
).setNegativeButton("String_Node_Str",new DialogInterface.OnClickListener(){
                        public void onClick(                        DialogInterface dialog,                        int which){
                          spinnertable.setSelection(0);
                        }
                      }
).create().show();
                    }
                  }
                }
);
              }
            }
            public void onNothingSelected(            AdapterView<?> arg0){
            }
          }
));
          TableRow tableheader=new TableRow(getApplicationContext());
          tableheader.setBackgroundColor(Color.BLACK);
          tableheader.setPadding(0,2,0,2);
          for (int k=0; k < c2.getColumnCount(); k++) {
            LinearLayout cell=new LinearLayout(AndroidDatabaseManager.this);
            cell.setBackgroundColor(Color.WHITE);
            cell.setLayoutParams(tableRowParams);
            final TextView tableheadercolums=new TextView(getApplicationContext());
            tableheadercolums.setPadding(0,0,4,3);
            tableheadercolums.setText("String_Node_Str" + c2.getColumnName(k));
            tableheadercolums.setTextColor(Color.parseColor("String_Node_Str"));
            cell.addView(tableheadercolums);
            tableheader.addView(cell);
          }
          tableLayout.addView(tableheader);
          c2.moveToFirst();
          paginatetable(c2.getCount());
        }
 else {
          help.setVisibility(View.GONE);
          tableLayout.removeAllViews();
          getcolumnnames();
          TableRow tableheader2=new TableRow(getApplicationContext());
          tableheader2.setBackgroundColor(Color.BLACK);
          tableheader2.setPadding(0,2,0,2);
          LinearLayout cell=new LinearLayout(AndroidDatabaseManager.this);
          cell.setBackgroundColor(Color.WHITE);
          cell.setLayoutParams(tableRowParams);
          final TextView tableheadercolums=new TextView(getApplicationContext());
          tableheadercolums.setPadding(0,0,4,3);
          tableheadercolums.setText("String_Node_Str");
          tableheadercolums.setTextSize(30);
          tableheadercolums.setTextColor(Color.RED);
          cell.addView(tableheadercolums);
          tableheader2.addView(cell);
          tableLayout.addView(tableheader2);
          tv.setText("String_Node_Str" + 0);
        }
      }
    }
    @Override public void onNothingSelected(    AdapterView<?> arg0){
    }
  }
);
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  dbm=new yourCustomSqlLiteHelperclass(AndroidDatabaseManager.this);
  mainscrollview=new ScrollView(AndroidDatabaseManager.this);
  mainLayout=new LinearLayout(AndroidDatabaseManager.this);
  mainLayout.setOrientation(LinearLayout.VERTICAL);
  mainLayout.setBackgroundColor(Color.WHITE);
  mainLayout.setScrollContainer(true);
  mainscrollview.addView(mainLayout);
  setContentView(mainscrollview);
  final LinearLayout firstrow=new LinearLayout(AndroidDatabaseManager.this);
  firstrow.setPadding(0,10,0,20);
  LinearLayout.LayoutParams firstrowlp=new LinearLayout.LayoutParams(0,150);
  firstrowlp.weight=1;
  TextView maintext=new TextView(AndroidDatabaseManager.this);
  maintext.setText("String_Node_Str");
  maintext.setTextSize(22);
  maintext.setLayoutParams(firstrowlp);
  select_table=new Spinner(AndroidDatabaseManager.this);
  select_table.setLayoutParams(firstrowlp);
  firstrow.addView(maintext);
  firstrow.addView(select_table);
  mainLayout.addView(firstrow);
  ArrayList<Cursor> alc;
  hsv=new HorizontalScrollView(AndroidDatabaseManager.this);
  tableLayout=new TableLayout(AndroidDatabaseManager.this);
  tableLayout.setHorizontalScrollBarEnabled(true);
  hsv.addView(tableLayout);
  final LinearLayout secondrow=new LinearLayout(AndroidDatabaseManager.this);
  secondrow.setPadding(0,20,0,10);
  LinearLayout.LayoutParams secondrowlp=new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT);
  secondrowlp.weight=1;
  TextView secondrowtext=new TextView(AndroidDatabaseManager.this);
  secondrowtext.setText("String_Node_Str");
  secondrowtext.setTextSize(20);
  secondrowtext.setLayoutParams(secondrowlp);
  tv=new TextView(AndroidDatabaseManager.this);
  tv.setTextSize(20);
  tv.setLayoutParams(secondrowlp);
  secondrow.addView(secondrowtext);
  secondrow.addView(tv);
  mainLayout.addView(secondrow);
  final EditText customquerytext=new EditText(this);
  customquerytext.setVisibility(View.GONE);
  customquerytext.setHint("String_Node_Str");
  mainLayout.addView(customquerytext);
  final Button submitQuery=new Button(AndroidDatabaseManager.this);
  submitQuery.setVisibility(View.GONE);
  submitQuery.setText("String_Node_Str");
  submitQuery.setBackgroundColor(Color.parseColor("String_Node_Str"));
  mainLayout.addView(submitQuery);
  final TextView help=new TextView(AndroidDatabaseManager.this);
  help.setText("String_Node_Str");
  help.setPadding(0,5,0,5);
  final Spinner spinnertable=new Spinner(AndroidDatabaseManager.this);
  mainLayout.addView(spinnertable);
  mainLayout.addView(help);
  hsv.setPadding(0,10,0,10);
  hsv.setScrollbarFadingEnabled(false);
  hsv.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_INSET);
  mainLayout.addView(hsv);
  final LinearLayout thirdrow=new LinearLayout(AndroidDatabaseManager.this);
  previous=new Button(AndroidDatabaseManager.this);
  previous.setText("String_Node_Str");
  previous.setBackgroundColor(Color.parseColor("String_Node_Str"));
  previous.setLayoutParams(secondrowlp);
  next=new Button(AndroidDatabaseManager.this);
  next.setText("String_Node_Str");
  next.setBackgroundColor(Color.parseColor("String_Node_Str"));
  next.setLayoutParams(secondrowlp);
  TextView tvblank=new TextView(this);
  tvblank.setLayoutParams(secondrowlp);
  thirdrow.setPadding(0,10,0,10);
  thirdrow.addView(previous);
  thirdrow.addView(tvblank);
  thirdrow.addView(next);
  mainLayout.addView(thirdrow);
  tvmessage=new TextView(AndroidDatabaseManager.this);
  tvmessage.setText("String_Node_Str");
  String Query="String_Node_Str";
  tvmessage.setTextSize(18);
  mainLayout.addView(tvmessage);
  final Button customQuery=new Button(AndroidDatabaseManager.this);
  customQuery.setText("String_Node_Str");
  customQuery.setBackgroundColor(Color.parseColor("String_Node_Str"));
  mainLayout.addView(customQuery);
  customQuery.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      indexInfo.isCustomQuery=true;
      secondrow.setVisibility(View.GONE);
      spinnertable.setVisibility(View.GONE);
      help.setVisibility(View.GONE);
      customquerytext.setVisibility(View.VISIBLE);
      submitQuery.setVisibility(View.VISIBLE);
      select_table.setSelection(0);
      customQuery.setVisibility(View.GONE);
    }
  }
);
  submitQuery.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      tableLayout.removeAllViews();
      customQuery.setVisibility(View.GONE);
      ArrayList<Cursor> alc2;
      String Query10=customquerytext.getText().toString();
      Log.d("String_Node_Str",Query10);
      alc2=dbm.getData(Query10);
      final Cursor c4=alc2.get(0);
      Cursor Message2=alc2.get(1);
      Message2.moveToLast();
      if (Message2.getString(0).equalsIgnoreCase("String_Node_Str")) {
        tvmessage.setBackgroundColor(Color.parseColor("String_Node_Str"));
        tvmessage.setText("String_Node_Str" + c4.getCount());
        if (c4.getCount() > 0) {
          indexInfo.maincursor=c4;
          refreshTable(1);
        }
      }
 else {
        tvmessage.setBackgroundColor(Color.parseColor("String_Node_Str"));
        tvmessage.setText("String_Node_Str" + Message2.getString(0));
      }
    }
  }
);
  tableRowParams=new TableRow.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
  tableRowParams.setMargins(0,0,2,0);
  alc=dbm.getData(Query);
  final Cursor c=alc.get(0);
  Cursor Message=alc.get(1);
  Message.moveToLast();
  String msg=Message.getString(0);
  Log.d("String_Node_Str",msg);
  ArrayList<String> tablenames=new ArrayList<String>();
  if (c != null) {
    c.moveToFirst();
    tablenames.add("String_Node_Str");
    do {
      tablenames.add(c.getString(0));
    }
 while (c.moveToNext());
  }
  ArrayAdapter<String> tablenamesadapter=new ArrayAdapter<String>(AndroidDatabaseManager.this,android.R.layout.simple_spinner_item,tablenames){
    public View getView(    int position,    View convertView,    ViewGroup parent){
      View v=super.getView(position,convertView,parent);
      v.setBackgroundColor(Color.WHITE);
      TextView adap=(TextView)v;
      adap.setTextSize(20);
      return adap;
    }
    public View getDropDownView(    int position,    View convertView,    ViewGroup parent){
      View v=super.getDropDownView(position,convertView,parent);
      v.setBackgroundColor(Color.WHITE);
      return v;
    }
  }
;
  tablenamesadapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  if (tablenamesadapter != null) {
    select_table.setAdapter(tablenamesadapter);
  }
  select_table.setOnItemSelectedListener(new OnItemSelectedListener(){
    @Override public void onItemSelected(    AdapterView<?> parent,    View view,    int pos,    long id){
      if (pos == 0 && !indexInfo.isCustomQuery) {
        secondrow.setVisibility(View.GONE);
        hsv.setVisibility(View.GONE);
        thirdrow.setVisibility(View.GONE);
        spinnertable.setVisibility(View.GONE);
        help.setVisibility(View.GONE);
        tvmessage.setVisibility(View.GONE);
        customquerytext.setVisibility(View.GONE);
        submitQuery.setVisibility(View.GONE);
        customQuery.setVisibility(View.GONE);
      }
      if (pos != 0) {
        secondrow.setVisibility(View.VISIBLE);
        spinnertable.setVisibility(View.VISIBLE);
        help.setVisibility(View.VISIBLE);
        customquerytext.setVisibility(View.GONE);
        submitQuery.setVisibility(View.GONE);
        customQuery.setVisibility(View.VISIBLE);
        hsv.setVisibility(View.VISIBLE);
        tvmessage.setVisibility(View.VISIBLE);
        thirdrow.setVisibility(View.VISIBLE);
        c.moveToPosition(pos - 1);
        indexInfo.cursorpostion=pos - 1;
        Log.d("String_Node_Str","String_Node_Str" + c.getString(0));
        indexInfo.table_name=c.getString(0);
        tvmessage.setText("String_Node_Str");
        tvmessage.setBackgroundColor(Color.WHITE);
        tableLayout.removeAllViews();
        ArrayList<String> spinnertablevalues=new ArrayList<String>();
        spinnertablevalues.add("String_Node_Str");
        spinnertablevalues.add("String_Node_Str");
        spinnertablevalues.add("String_Node_Str");
        spinnertablevalues.add("String_Node_Str");
        ArrayAdapter<String> spinnerArrayAdapter=new ArrayAdapter<String>(getApplicationContext(),android.R.layout.simple_spinner_dropdown_item,spinnertablevalues);
        spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_item);
        ArrayAdapter<String> adapter=new ArrayAdapter<String>(AndroidDatabaseManager.this,android.R.layout.simple_spinner_item,spinnertablevalues){
          public View getView(          int position,          View convertView,          ViewGroup parent){
            View v=super.getView(position,convertView,parent);
            v.setBackgroundColor(Color.WHITE);
            TextView adap=(TextView)v;
            adap.setTextSize(20);
            return adap;
          }
          public View getDropDownView(          int position,          View convertView,          ViewGroup parent){
            View v=super.getDropDownView(position,convertView,parent);
            v.setBackgroundColor(Color.WHITE);
            return v;
          }
        }
;
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spinnertable.setAdapter(adapter);
        String Query2="String_Node_Str" + c.getString(0);
        Log.d("String_Node_Str","String_Node_Str" + Query2);
        ArrayList<Cursor> alc2=dbm.getData(Query2);
        final Cursor c2=alc2.get(0);
        indexInfo.maincursor=c2;
        if (c2 != null) {
          int counts=c2.getCount();
          indexInfo.isEmpty=false;
          Log.d("String_Node_Str","String_Node_Str" + counts);
          tv.setText("String_Node_Str" + counts);
          spinnertable.setOnItemSelectedListener((new AdapterView.OnItemSelectedListener(){
            @Override public void onItemSelected(            AdapterView<?> parentView,            View selectedItemView,            int position,            long id){
              ((TextView)parentView.getChildAt(0)).setTextColor(Color.rgb(0,0,0));
              if (spinnertable.getSelectedItem().toString().equals("String_Node_Str")) {
                runOnUiThread(new Runnable(){
                  @Override public void run(){
                    if (!isFinishing()) {
                      new AlertDialog.Builder(AndroidDatabaseManager.this).setTitle("String_Node_Str").setMessage("String_Node_Str" + indexInfo.table_name + "String_Node_Str").setPositiveButton("String_Node_Str",new DialogInterface.OnClickListener(){
                        public void onClick(                        DialogInterface dialog,                        int which){
                          String Query6="String_Node_Str" + indexInfo.table_name;
                          ArrayList<Cursor> aldropt=dbm.getData(Query6);
                          Cursor tempc=aldropt.get(1);
                          tempc.moveToLast();
                          Log.d("String_Node_Str",tempc.getString(0));
                          if (tempc.getString(0).equalsIgnoreCase("String_Node_Str")) {
                            tvmessage.setBackgroundColor(Color.parseColor("String_Node_Str"));
                            tvmessage.setText(indexInfo.table_name + "String_Node_Str");
                            refreshactivity();
                          }
 else {
                            tvmessage.setBackgroundColor(Color.parseColor("String_Node_Str"));
                            tvmessage.setText("String_Node_Str" + tempc.getString(0));
                            spinnertable.setSelection(0);
                          }
                        }
                      }
).setNegativeButton("String_Node_Str",new DialogInterface.OnClickListener(){
                        public void onClick(                        DialogInterface dialog,                        int which){
                          spinnertable.setSelection(0);
                        }
                      }
).create().show();
                    }
                  }
                }
);
              }
              if (spinnertable.getSelectedItem().toString().equals("String_Node_Str")) {
                runOnUiThread(new Runnable(){
                  @Override public void run(){
                    if (!isFinishing()) {
                      new AlertDialog.Builder(AndroidDatabaseManager.this).setTitle("String_Node_Str").setMessage("String_Node_Str" + indexInfo.table_name + "String_Node_Str").setPositiveButton("String_Node_Str",new DialogInterface.OnClickListener(){
                        public void onClick(                        DialogInterface dialog,                        int which){
                          String Query7="String_Node_Str" + indexInfo.table_name;
                          Log.d("String_Node_Str",Query7);
                          ArrayList<Cursor> aldeletet=dbm.getData(Query7);
                          Cursor tempc=aldeletet.get(1);
                          tempc.moveToLast();
                          Log.d("String_Node_Str",tempc.getString(0));
                          if (tempc.getString(0).equalsIgnoreCase("String_Node_Str")) {
                            tvmessage.setBackgroundColor(Color.parseColor("String_Node_Str"));
                            tvmessage.setText(indexInfo.table_name + "String_Node_Str");
                            indexInfo.isEmpty=true;
                            refreshTable(0);
                          }
 else {
                            tvmessage.setBackgroundColor(Color.parseColor("String_Node_Str"));
                            tvmessage.setText("String_Node_Str" + tempc.getString(0));
                            spinnertable.setSelection(0);
                          }
                        }
                      }
).setNegativeButton("String_Node_Str",new DialogInterface.OnClickListener(){
                        public void onClick(                        DialogInterface dialog,                        int which){
                          spinnertable.setSelection(0);
                        }
                      }
).create().show();
                    }
                  }
                }
);
              }
              if (spinnertable.getSelectedItem().toString().equals("String_Node_Str")) {
                final LinkedList<TextView> addnewrownames=new LinkedList<TextView>();
                final LinkedList<EditText> addnewrowvalues=new LinkedList<EditText>();
                final ScrollView addrowsv=new ScrollView(AndroidDatabaseManager.this);
                Cursor c4=indexInfo.maincursor;
                if (indexInfo.isEmpty) {
                  getcolumnnames();
                  for (int i=0; i < indexInfo.emptytablecolumnnames.size(); i++) {
                    String cname=indexInfo.emptytablecolumnnames.get(i);
                    TextView tv=new TextView(getApplicationContext());
                    tv.setText(cname);
                    addnewrownames.add(tv);
                  }
                  for (int i=0; i < addnewrownames.size(); i++) {
                    EditText et=new EditText(getApplicationContext());
                    addnewrowvalues.add(et);
                  }
                }
 else {
                  for (int i=0; i < c4.getColumnCount(); i++) {
                    String cname=c4.getColumnName(i);
                    TextView tv=new TextView(getApplicationContext());
                    tv.setText(cname);
                    addnewrownames.add(tv);
                  }
                  for (int i=0; i < addnewrownames.size(); i++) {
                    EditText et=new EditText(getApplicationContext());
                    addnewrowvalues.add(et);
                  }
                }
                final RelativeLayout addnewlayout=new RelativeLayout(AndroidDatabaseManager.this);
                RelativeLayout.LayoutParams addnewparams=new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
                addnewparams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
                for (int i=0; i < addnewrownames.size(); i++) {
                  TextView tv=addnewrownames.get(i);
                  EditText et=addnewrowvalues.get(i);
                  int t=i + 400;
                  int k=i + 500;
                  int lid=i + 600;
                  tv.setId(t);
                  tv.setTextColor(Color.parseColor("String_Node_Str"));
                  et.setBackgroundColor(Color.parseColor("String_Node_Str"));
                  et.setTextColor(Color.parseColor("String_Node_Str"));
                  et.setId(k);
                  final LinearLayout ll=new LinearLayout(AndroidDatabaseManager.this);
                  LinearLayout.LayoutParams tvl=new LinearLayout.LayoutParams(0,100);
                  tvl.weight=1;
                  ll.addView(tv,tvl);
                  ll.addView(et,tvl);
                  ll.setId(lid);
                  Log.d("String_Node_Str","String_Node_Str" + et.getText().toString());
                  RelativeLayout.LayoutParams rll=new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
                  rll.addRule(RelativeLayout.BELOW,ll.getId() - 1);
                  rll.setMargins(0,20,0,0);
                  addnewlayout.addView(ll,rll);
                }
                addnewlayout.setBackgroundColor(Color.WHITE);
                addrowsv.addView(addnewlayout);
                Log.d("String_Node_Str","String_Node_Str");
                runOnUiThread(new Runnable(){
                  @Override public void run(){
                    if (!isFinishing()) {
                      new AlertDialog.Builder(AndroidDatabaseManager.this).setTitle("String_Node_Str").setCancelable(false).setView(addrowsv).setPositiveButton("String_Node_Str",new DialogInterface.OnClickListener(){
                        public void onClick(                        DialogInterface dialog,                        int which){
                          indexInfo.index=10;
                          String Query4="String_Node_Str" + indexInfo.table_name + "String_Node_Str";
                          for (int i=0; i < addnewrownames.size(); i++) {
                            TextView tv=addnewrownames.get(i);
                            tv.getText().toString();
                            if (i == addnewrownames.size() - 1) {
                              Query4=Query4 + tv.getText().toString();
                            }
 else {
                              Query4=Query4 + tv.getText().toString() + "String_Node_Str";
                            }
                          }
                          Query4=Query4 + "String_Node_Str";
                          for (int i=0; i < addnewrownames.size(); i++) {
                            EditText et=addnewrowvalues.get(i);
                            et.getText().toString();
                            if (i == addnewrownames.size() - 1) {
                              Query4=Query4 + "String_Node_Str" + et.getText().toString()+ "String_Node_Str";
                            }
 else {
                              Query4=Query4 + "String_Node_Str" + et.getText().toString()+ "String_Node_Str";
                            }
                          }
                          Log.d("String_Node_Str",Query4);
                          ArrayList<Cursor> altc=dbm.getData(Query4);
                          Cursor tempc=altc.get(1);
                          tempc.moveToLast();
                          Log.d("String_Node_Str",tempc.getString(0));
                          if (tempc.getString(0).equalsIgnoreCase("String_Node_Str")) {
                            tvmessage.setBackgroundColor(Color.parseColor("String_Node_Str"));
                            tvmessage.setText("String_Node_Str" + indexInfo.table_name);
                            refreshTable(0);
                          }
 else {
                            tvmessage.setBackgroundColor(Color.parseColor("String_Node_Str"));
                            tvmessage.setText("String_Node_Str" + tempc.getString(0));
                            spinnertable.setSelection(0);
                          }
                        }
                      }
).setNegativeButton("String_Node_Str",new DialogInterface.OnClickListener(){
                        public void onClick(                        DialogInterface dialog,                        int which){
                          spinnertable.setSelection(0);
                        }
                      }
).create().show();
                    }
                  }
                }
);
              }
            }
            public void onNothingSelected(            AdapterView<?> arg0){
            }
          }
));
          TableRow tableheader=new TableRow(getApplicationContext());
          tableheader.setBackgroundColor(Color.BLACK);
          tableheader.setPadding(0,2,0,2);
          for (int k=0; k < c2.getColumnCount(); k++) {
            LinearLayout cell=new LinearLayout(AndroidDatabaseManager.this);
            cell.setBackgroundColor(Color.WHITE);
            cell.setLayoutParams(tableRowParams);
            final TextView tableheadercolums=new TextView(getApplicationContext());
            tableheadercolums.setPadding(0,0,4,3);
            tableheadercolums.setText("String_Node_Str" + c2.getColumnName(k));
            tableheadercolums.setTextColor(Color.parseColor("String_Node_Str"));
            cell.addView(tableheadercolums);
            tableheader.addView(cell);
          }
          tableLayout.addView(tableheader);
          c2.moveToFirst();
          paginatetable(c2.getCount());
        }
 else {
          help.setVisibility(View.GONE);
          tableLayout.removeAllViews();
          getcolumnnames();
          TableRow tableheader2=new TableRow(getApplicationContext());
          tableheader2.setBackgroundColor(Color.BLACK);
          tableheader2.setPadding(0,2,0,2);
          LinearLayout cell=new LinearLayout(AndroidDatabaseManager.this);
          cell.setBackgroundColor(Color.WHITE);
          cell.setLayoutParams(tableRowParams);
          final TextView tableheadercolums=new TextView(getApplicationContext());
          tableheadercolums.setPadding(0,0,4,3);
          tableheadercolums.setText("String_Node_Str");
          tableheadercolums.setTextSize(30);
          tableheadercolums.setTextColor(Color.RED);
          cell.addView(tableheadercolums);
          tableheader2.addView(cell);
          tableLayout.addView(tableheader2);
          tv.setText("String_Node_Str" + 0);
        }
      }
    }
    @Override public void onNothingSelected(    AdapterView<?> arg0){
    }
  }
);
}