1

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);
    }
3
  • where is your database code? Commented Jul 22, 2013 at 8:13
  • Use SQLITE ? developer.android.com/reference/android/database/sqlite/… Commented Jul 22, 2013 at 8:17
  • what exactly is the problem you are facing? Are you able to get feelingForDb from DB? If yes, then you can simply pass this string as part of gotoNeeds intent. Use gotoNeeds.putExtra("some_identifier_name", feelingForDb); and in the Needs class you will need to retrieve it using getIntent().getStringExtra("some_identifier_name"); Commented Jul 22, 2013 at 8:19

1 Answer 1

1

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
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.