Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to solve this error in tab menu with database?
    primarykey
    data
    text
    <p>In my app I have tab menu : Add tab,View tab.</p> <p>in Add tab: I add data to database in View tab: I select data from database into listview</p> <p><strong>now</strong> I have problem: when I add a data from add tab and switch into viewtab I can't view last adding into database, but if I close app and open it new time, i can get last adding</p> <p>any idea about solve of this problem please</p> <p>Code :</p> <p>`view tab code:</p> <p>public class ViewEvents extends Activity {</p> <pre><code>DBAdapter DB=new DBAdapter(this); public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.viewevents); final ListView myListView = (ListView)findViewById(R.id.MyList); // final EditText myEditText = (EditText)findViewById(R.id.myEditText); // Create the array list of to do items final ArrayList&lt;String&gt; todoItems = new ArrayList&lt;String&gt;(); final ArrayAdapter&lt;String&gt; aa = new ArrayAdapter&lt;String&gt;(this,android.R.layout.simple_list_item_1, todoItems); DB.open(); Cursor c=DB.select(); c.moveToFirst(); Integer n=new Integer(c.getCount()); for(int i=0;i&lt;c.getCount();i++) { todoItems.add(0, c.getString(0)); c.moveToNext(); } // todoItems.add(0, c.getString(0)); aa.notifyDataSetChanged(); myListView.setAdapter(aa); } </code></pre> <h2>}</h2> <p>add tab code:</p> <p>public View getView(int position, View convertView, ViewGroup parent) {</p> <pre><code> ButtonHolder holder2; if (convertView == null) { holder2 = new ButtonHolder(); convertView = mInflater.inflate(R.layout.item, null); holder2.caption = (Button) convertView.findViewById(R.id.Bte); convertView.setTag(holder2); } else { holder2 = (ButtonHolder) convertView.getTag(); } holder2.caption.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub TextView names = holderpartner.caption; TextView date = holderdv.caption; TextView time = holderviewmtime.caption; String address = "sdfgkhj"; event e=new event( names.getText().toString(), address,date.getText().toString(), new java.sql.Time(9, 30, 30)); DB.open(); DB.insertTask(e); date.setText(""); time.setText(""); Toast.makeText(getBaseContext(), "Done",Toast.LENGTH_LONG).show(); } });` </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload