Question

I have two activities and a database. I want to send the data from the first activity to the data base and then move to the next activity. I know this is wrong but it is the best I could find online, any other ways of doing it?

OnItemClickListener viewNeeds = new OnItemClickListener(){

    @Override
    public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
            long arg3) {
        // TODO Auto-generated method stub
        //create variable for database input
        feelingForDb = ((AdapterView<ListAdapter>) feelingsList).getSelectedItem().toString();
        Intent gotoNeeds=
                new Intent(FeelingsMain.this, Needs.class);
        startActivity(gotoNeeds);
    }
Était-ce utile?

La solution

on First activity insert data to data base when its inserted start next activity

your insertData function of database class, should return long type data

like

long success = db.insert(tableName, null, values);
     return success;

than inside First Activity

if(longReturned>0)
{
//startActivity2 here
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top