This works.
Thanks for your help
On Apr 11, 2:32 am, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> Hi,
> Some time ago I submitted this entry to the group. It is a fast way
> to include your db in the databases folder.
> Hope it helps.
> Omar Flores
>
> Fast way to copy a sqlite db from Assets to /data/data/yourApp/
> databases folder
>
> From: OmarFlores <[EMAIL PROTECTED]>
> Date: Thu, 27 Mar 2008 13:08:15 -0700 (PDT)
> Local: Thurs, Mar 27 2008 4:08 pm
> Subject: Fast way to copy a sqlite db from Assets to /data/data/
> yourApp/databases folder
> Reply | Reply to author | Forward | Print | Individual message | Show
> original | Remove | Report this message | Find messages by this author
> 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
> inhttp://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.
>
> On Apr 9, 12:38 pm, "Kyara" <[EMAIL PROTECTED]> wrote:
>
> > Hi AL,
>
> > You can include your data set in .apk resource and unload it from the
> > resource to your database. Your app can even use the data directly from the
> > resource file, for demonstration purpose.
>
> > SQLite is kinda slow on volume of row insertion, though.
>
> > Peter
>
> > ----- Original Message -----
> > From: "AL" <[EMAIL PROTECTED]>
> > To: "Android Challenge" <[email protected]>
> > Sent: Wednesday, April 09, 2008 2:45 AM
> > Subject: [android-challenge] Can't include initial database -> Cant submit
>
> > entry to developer challenge
>
> > > I've spent at least 50 hours developing my entry for the android dev
> > > challenge but now I cant submit it because i need test data in my
> > > SQLite database or the app is an empty shell. The only way i can
> > > populate my database is to run execSQL(); one insert statement at a
> > > time, which takes about 15 minutes during startup, and i dont expect
> > > anyone to wait more than a few seconds.. And my database size is only
> > > 11 kilobytes on disk ... the apk file lets you include xml, drawables,
> > > and raw data but no sql databases, why?
>
> > > have i missed something here or is my entry dead in the water...?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Android Challenge" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-challenge?hl=en
-~----------~----~----~----~------~----~------~--~---