Content Providers and Database initialisation

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


Sponsored Links
 Hey,
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,

Gav

--~--~---------~--~----~------------~-------~--~----~



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?

thanks!



--~--~---------~--~----~------------~-------~--~----~


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.

 http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/ 


Justin






--~--~---------~--~----~------------~-------~--~----~



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.

Hi,

I am trying to use the PreviewCallback but i get an IOException
saying:
"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
android)

----
public class CamApp extends Activity implements Camera.PreviewCallback
{

     @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        SurfaceView surfView = new SurfaceView(this);
        setContentView(surfView);

        Camera cam = Camera.open();
        Camera.Parameters parameters = cam.getParameters();
        parameters.setPreviewSize(100, 100);
        cam.setParameters(parameters);
        cam.setPreviewCallback(this);
        cam.startPreview();

    }

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

     }

}

---------

Stack:

Thread [<3> main] (Suspended (exception RuntimeException))
   ActivityThread.performLaunchActivity(ActivityThread$ActivityRecord)
line: 2140   <--- Here is where i can see the IOException
   ActivityThread.handleLaunchActivity(ActivityThread$ActivityRecord)
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$MethodAndArgsCaller.run() 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)

Hello,


Need some clarification on the following behavior:

Case a:

I have a very simple Activity:"MyBrowser", which has a linear layout and
loads "mail.google.com" 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. */
    @Override
    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        this.browser = new WebView(this);
        browser.getSettings().setJavaScriptEnabled(true);

        browser.loadUrl("http://mail.google.com");
        setContentView(browser);
    }


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


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


Any suggestion appreciated.


Thank You,

Kumar    _/|\_
www.saisk.com
[EMAIL PROTECTED]
"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