On Wed, May 12, 2010 at 7:25 PM, brucko geoff.bruck...@gmail.com wrote:
This all sounds like a local Service to me. Open the db in onBind if
its not open. Let the service take care of how many Activities/
Services are bound and close the db in onUnbind.
If you don't have a reference to the db
Sebastián Treu wrote:
On Wed, May 12, 2010 at 7:25 PM, brucko geoff.bruck...@gmail.com wrote:
This all sounds like a local Service to me. Open the db in onBind if
its not open. Let the service take care of how many Activities/
Services are bound and close the db in onUnbind.
If you don't
I'm not sure if you guys have looked into reference counting, but that
sounds like a possible solution to me. If you use a static reference
count in your database helper object, your close method can only close
the connection if there's just one reference left. I'm actually still
working through
This all sounds like a local Service to me. Open the db in onBind if
its not open. Let the service take care of how many Activities/
Services are bound and close the db in onUnbind.
Easy, simple everything you need is already there.
Or you can complicate things and reinvent singletons and
As am I, I'm doing the same with onPause/onResume.
Federico how are you checking if your database connection is open?
On Apr 28, 3:18 am, Federico Paolinelli fedep...@gmail.com wrote:
An sqllitedb (helper) object for each activity (but the open one is
only in the active activity). Every time
Just putting a dbstatus flag in the dbhelper class.
When open() is called, I check the flag to see if the db is already
open, if so I do nothing, otherwise I do the open stuff and then I set
the flag.
On Thu, Apr 29, 2010 at 2:26 PM, gcstang gcst...@gmail.com wrote:
As am I, I'm doing the same
An sqllitedb (helper) object for each activity (but the open one is
only in the active activity). Every time an activity closes or pauses,
I call the close() method.
However, I am interested in any more elegant and standard solution of
this problem.
Federico
On 27 Apr, 21:49, goosedroid
On 27 Apr, 13:48, goosedroid alexrhel...@gmail.com wrote:
I have been trying to find a discussion on the best way to handle a
common sqlite database which is shared by multiple Activities (or
multiple Activities and Services). This is all in the same
application.
It seems that if each
There is a standard way of doing this in Android: ContentProvider. It
is so important that there is a whole chapter written about it in the
Developer's Guide:
http://developer.android.com/guide/topics/providers/content-providers.html
Also, look at the Notepad example, as others have suggested.
Brian,
Thanks for your response. However as mentioned in the OP, all
activities and services are in the same application. From what I
understand, ContentProvider is for exposing and consuming data outside
of your application, but this is not my scenario.
On Apr 27, 11:34 am, Brion Emde
Martin, thanks for your response. The lifecycles of my Activities and
Services are independent from each other. The Service may be writing
to the database while no Activities are active. OTOH, an Activity may
be viewing data while the Service is not running.
So I'm not sure who would be
Frederico, were you sharing the same SQLiteDatabase instance object
between all activities via some singleton helper class, or was each
Activity instantiating a new SQLiteDatabase object?
On Apr 27, 8:58 am, Federico Paolinelli fedep...@gmail.com wrote:
On 27 Apr, 13:48, goosedroid
12 matches
Mail list logo