3

Is there any way to pass database object between activities. I have already tried the following ways for doing this.

  1. Implementing interface.
  2. Using functions.
Haisum Abbas
  • 31
  • 1
  • 2

2 Answers2

5

I guess you are looking for a Singleton. Maybe this will help you:

If you are using a SQLiteOpenHelper I HIGHLY recommend you to read this:

I think you should be fine with Approach #1 which uses a singleton with the abstract factory pattern. Read the article its very informative. More on the topic and Pros n cons are here

Community
  • 1
  • 1
Langusten Gustel
  • 10,917
  • 9
  • 46
  • 59
-1

There are several approaches that you can follow such as the use of Intent.putExtra() to pass your data objects from one activity to another