If you need to provide data to other applications, consider implementing a ContentProvider:

http://developer.android.com/reference/android/content/ContentProvider.html

This has the following benefits in your described use scenario:

- You can protect your data by declaring read and/or write permissions for the content provider in your manifest;

- CP lifecycle is managed by Android, it will be loaded and initialized as soon as it's needed (based on the authority URI);

- You keep implementation details private to your CP code (the database schema, the mapping between URIs and tables, etc.);

- Your CP will be instantiated only once, so you won't need to solve any problems like "is the database already open, and in which process";

- The framework provides URI-based data update notifications that can be observed by ListViews and their CursorAdapters, so you can get "live" views into your data at little or no extra effort.

If you're creating custom firmware with your application pre-installed, you can still use a CP and get the benefits described above, but in addition, you can require that only applications signed with the firmware key are able to get write access to your data (for an example, look at the standard email application in Android source).

-- Kostya

12.01.2011 18:54, androiddevelopers пишет:
Hi,

I want to create an database for my service . as of now we are creating the database on invocation of the service.
Here we create the Database and add default values and it works.

My Need : I want to have a database as part of the system image ( That is when i flash the image/APK) . The database should be present already rather than me populating when i launch the service.here my use case is that database can be accessed by any app in read only mode but the database value is written by my service only.so i just want the database being present , before my service is launched so that any app can access the database.




Gs
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


--
Kostya Vasilyev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to