How can i update a database from another activity? How can i update a database from another activity? sqlite sqlite

How can i update a database from another activity?


You have to define an indipendent class to interact with db, not to include the code in an activity. Better you have to use ContentProvider.


use this code

Sorry My English is Not to Good .. SO please ingore it.

**DBAadapter db = new DBAadapter(this);        db.open();        thou = db.getAllFamilyMembers();        Log.v("log"," thoughts " + thou);         db.close();**

In this DBAadapter is which class when your database open close method.

And getAllFamilyMembers() is the DBAadapter class method.

then you get data in other activity using Above code.


You are in for trouble extending SQLiteOpenHelper. As stated by the documentation it is for managing creating and updates(when updating published apps). Please save yourself a lot of grief later, and look into SQLitedatebase and more specific SQLiteClosable.

http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html

The relevant code for a more direct answers is in your helper class. But... Save yourself :-)