Hi Guys,
I have SQLite DB of size around 10MB. I want to access this database in my
monodroid application. To achieve this functionality I have followed
following steps.
1) Put SQLite DB file in Asset folder.
2) Checked the existence of DB in device memory.
3) If DB is not present then copied DB to device memory.
Below is the code snippet which I used to copy DB to device.
//Open your local db as the input stream
Stream myInput = myContext.Assets.Open(DB_NAME);
// Path to the just created empty db
string outFileName = DB_PATH + DB_NAME;
//Open the empty db as the output stream
Stream myOutput = new FileStream(outFileName, FileMode.OpenOrCreate);
//transfer bytes from the inputfile to the outputfile
byte[] buffer = new byte[1024];
int b = buffer.Length;
int length;
while ((length = myInput.Read(buffer, 0, b)) > 0)
{
myOutput.Write(buffer, 0, length);
}
//Close the streams
myOutput.Flush();
myOutput.Close();
myInput.Close();
4) Once the DB is copied, opened the database and executed the SQL
statements. Below is the code snippet.
String myPath = DB_PATH + DB_NAME;
myDataBase = SQLiteDatabase.OpenDatabase(myPath, null,
DatabaseOpenFlags.OpenReadonly);
The above step works fine when DB is of less size with very less records
(around 500 records). But as I am using huge DB file i am getting error
while copying the DB. (i.e Step 3)
I have taken help from below link
http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/
Please help me with your suggestion or code sample.
Thanks
S.Rahman
--
View this message in context:
http://mono-for-android.1047100.n5.nabble.com/Error-while-copying-SQLite-database-tp4723722p4723722.html
Sent from the Mono for Android mailing list archive at Nabble.com.
_______________________________________________
Monodroid mailing list
[email protected]
UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid