Content Providers and Database initialisation

by Gavin Aiken » Wed, 18 Feb 2009 20:54:14 GMT

Sponsored Links
I have a plethora of data which is currently stored in 1000 different very
small text files, I want to store this data in an SQLite database as I feel
that this will be more space efficient and hopefully time efficient as I
presume a database query is faster than opening and parsing a text file
(please stop me now if this isn't the case!).

The data does not need to be available to other applications and will be
used internally only. My first question is whether or not to create a
content provider anyway, is there any benefit to this?

My second question is where to initialize the database, is it possible to
ship an application with a database included already populated? Do I have to
populate it in the onCreate method of the SQLiteOpenHelper subclass? If I
have to include the 1000 text files and read, parse and insert the data at
install time I have a feeling this would be slow. Is it possible for me to
populate the database now, dump it to a single file and then bulk insert
from the file in the onCreate method?

I hope you get the jist of what I mean!

Many thanks,



Content Providers and Database initialisation

by daekpony » Fri, 06 Mar 2009 09:01:14 GMT

 hi there - did you ever get an answer to whether you can ship an
application with the database already populated? If you can, would you
mind sharing the steps to do so with us?



Sponsored Links

Content Providers and Database initialisation

by Justin Allen Jaynes » Sat, 07 Mar 2009 11:35:49 GMT

 I had a similar question and Alistair Rutherford shared this article 
link with me.  It's exactly what I was looking for and may help you as well. 



Other Threads

1. I am trying to use the PreviewCallback but i get an IOException saying: "startPreview failed". I run the emulator in the debugger.


I am trying to use the PreviewCallback but i get an IOException
"startPreview failed". I run the emulator in the de{*filter*}.   Is there
a complete sample somewhere using the PreviewCallback. I have now for
great ideas of applications that i want to make but they all use the
the PreviewCallback since i want to be able put overlays and filter
what is seen through the camera. I have tried other forums for help
but it i cant get any and that is probably because there is a bug in
how the data parameter to the callback is represented.

(However i am very grateful for such a good SDK and emulator..  love

public class CamApp extends Activity implements Camera.PreviewCallback

    public void onCreate(Bundle savedInstanceState) {

        SurfaceView surfView = new SurfaceView(this);

        Camera cam =;
        Camera.Parameters parameters = cam.getParameters();
        parameters.setPreviewSize(100, 100);


     public void onPreviewFrame(byte[] data, Camera camera) {





Thread [<3> main] (Suspended (exception RuntimeException))
line: 2140   <--- Here is where i can see the IOException
line: 2156
   ActivityThread.access$1800(ActivityThread, ActivityThread
$ActivityRecord) line: 112
   ActivityThread$H.handleMessage(Message) line: 1580
   ActivityThread$H(Handler).dispatchMessage(Message) line: 88
   Looper.loop() line: 123
   ActivityThread.main(String[]) line: 3742
   Method.invokeNative(Object, Object[], Class, Class[], Class, int,
boolean) line: not available [native method]
   Method.invoke(Object, Object...) line: 515
   ZygoteInit$ line: 739
   ZygoteInit.main(String[]) line: 497
   NativeStart.main(String[]) line: not available [native method]


2. WebKit: WebView loading https site (redirection losing form values)


Need some clarification on the following behavior:

Case a:

I have a very simple Activity:"MyBrowser", which has a linear layout and
loads "" in the onCreate() method using WebView.
(Code below). When I enter the gmail username and password it opens a new
browser window (Load Browser Activity) and  moves "Mybrowser" activity to
the back ground and opens a browser window with error message saying
"Required Fields cannot be left blank...." and now if I retype the gmail
username and password it logs me into my gmail account.

private WebView browser;

    /** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState) {


        this.browser = new WebView(this);


Case b: When I open the browser, and enter as the URL ... it
captures my username/password in the first time and directly takes me to the

Has anyone solved this problem or has a theory behind this behavior.

Any suggestion appreciated.

Thank You,

Kumar    _/|\_
"making a profound difference with knowledge and creativity..."


3. K-9 email growing size

4. Accessing a specific email

5. Clearing or disabling browser cache

6. What is google's official position on JNI ?

7. problem in unzipping ramdisk CPIO archive