Hi,

If someone might need a way to send a sqlite db with the app and then
to copy it to a directory such as /data/data/yourApp/databases, here
is a fast way to do it:

Place the db file in the assets folder (this example can be found in:
droiddraw.org | Tutorials | Third Party Tutorials by Omar F, or in
http://coreintent.googlepages.com/ )

Use the following code:

/**
 * Demonstration of styled text resources.
 */
public class assets extends Activity
{
            @Override
        protected void onCreate(Bundle icicle)
    {
        super.onCreate(icicle);

        // See assets/res/any/layout/styled_text.xml for this
        // view layout definition.
        setContentView(R.layout.read_asset);

        try {
            // Open the file
            InputStream in = getAssets().open("psalmsdb");

            // Open the output file
            String outFilename = "/data/data/com.assets/databases/
psalmsdb33";
            OutputStream out = new FileOutputStream(outFilename);

            // Transfer bytes from the input file to the output file
            byte[] buf = new byte[1024];
            int len;
            while ((len = in.read(buf)) > 0) {
                out.write(buf, 0, len);
            }

            // Close the streams
            out.close();
            in.close();
        } catch (IOException e) {
        }
        AlertDialog.show(this, "mensaje",1, "finished", "Cancel",
false);
       }
}

Cheers,

Omar Flores.

PS: Thanks to Zach Hobbs for pointing me in the right direction when I
was looking for a way to include the db in the delivery package.
Other 'credits' can be found in the above link.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to