Pergunta

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);
    }
Foi útil?

Solução

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
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top