Initial database population from large data files, several problems

by Alistair. » Fri, 06 Mar 2009 17:37:38 GMT


Sponsored Links
 Justin,

You might find this article of interest. This is a technique to pre-
populate the database and bundle into the assets directory of your
application.

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

Al.



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



Initial database population from large data files, several problems

by Jesse McGrew » Sat, 07 Mar 2009 10:53:25 GMT


 


Pre-populating it and building the database file into your app, as the
other response suggested, is probably the best way to do it.

However, if you decide to populate the database when your app is first
run, you might still be able to speed it up by wrapping the whole
process inside an SQLite transaction. Otherwise, it creates a separate
transaction for each query, which is slow. That's according to the
SQLite Optimization FAQ ( http://web.utk.edu/ ~jplyon/sqlite/
SQLite_optimization_FAQ.html), although that FAQ is out of date by now
so maybe it's no longer true.

Jesse

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


Sponsored Links


Initial database population from large data files, several problems

by Justin Allen Jaynes » Sat, 07 Mar 2009 16:49:02 GMT


 Alistair,

This is precisely the approach I was looking for.  Thank you--most 
invaluable to me.

Justin






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



Initial database population from large data files, several problems

by Justin Allen Jaynes » Sun, 08 Mar 2009 11:09:58 GMT


 listair,

I'm having a little trouble actually implementing the code from that
forum. It's an IOException I'm getting, and I've tracked it down to the
exact line in my code.

What I've done so far:

1. created the database file named wordlist.db and placed it in the
assets folder of my Eclipse Package Explorer Tree. (I'm certain this
database file is good--at least on my desktop machine--who knows what's
happening when it goes to the phone)
2. adapted the code to my purose.
3. after getting an IOException, I commented out all the lines of code
in the method copyDataBase, and then added them back in one at a time
until the exception was thrown again.
4. I simplified the code just to be sure and removed the while loop,
replacing it with: myInput.read(buffer); but I still throw an error when
this line is not commented out.

Is there a way to see a more specific error than just IOException, and
if not, what might be a possible cause for being unable to read a byte
block from the file?

My code:

public void onCreate(SQLiteDatabase db) {
try {
copyDataBase();
} catch (IOException e) {
throw new Error("Error copying database " + e);
}
}

private void copyDataBase() throws IOException{

//Open your local db as the input stream
InputStream myInput = myContext.getAssets().open("wordlist.db");

// Path to the just created empty db
String outFileName = DATABASE_PATH + "wordlist.db";

//Open the empty db as the output stream
//OutputStream myOutput = new FileOutputStream(outFileName);

//transfer bytes from the inputfile to the outputfile
byte[] buffer = new byte[1024];
int length;
while ((length = myInput.read(buffer)) > 0) {
// myOutput.write(buffer, 0, length);
}

//Close the streams
//myOutput.flush();
//myOutput.close();
myInput.close();

}


Alistair. wrote:


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



Initial database population from large data files, several problems

by pawpaw17 » Thu, 30 Apr 2009 01:24:06 GMT


 Justin,

I get the same exact error as you do. My thinking is it is because our
DB files are too
big. Have you made any progress on this?

Thanks,
--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. How a phone application can be separated from vt application?

Hi,
I am dinesh , right now working with phone application we have used VT
actvity inside phone for videotelephony and we are also using many of phone
utilities inside it, now for maintainance purpose we have to move the VT out
of phone application we thought of keeping VT and Phone as two APK under one
process that is phone process..since we have lot of dependencies in it..can
someone suggest the best way to separate the dependencies from phone
application ?

-- 

2. The connection of bletooth with multi devices using SPP.

Hi ~

I could connect to two devices from Android based cell phone
simultaneously using SPP, but once I turn on the inputstream, one of
them will return 0 in the stream.
For example, thread A(thA) and thread B(thB) connected to device
A(devA) and device B(devB) respectively. So,  thA uses inputstream
A(inA) to receive data from devA, thB uses inputstream B(inB) to
receive data from devB. As follow:
devA --->inA --->thA
devB --->inB --->thB
It works fine if I connect to each device separately. However, in the
case of connecting two devices at the same time, then only inA or inB
has data on it.

If it happens to you, please share your experence with me, I would be
very appreciated!!
Thank you in advance.
YT

-- 

3. How can I sign my test application with Android Browser application certificate?

4. Getting Error 鈥淚nstallation e rror: INSTALL_FAILED_MISSING_SHARED_LIBRARY鈥

5. read only file system

6. Thread crash if activity is restarted

7. Connection with eclipse ganymade