[mono-android] Error while copying SQLite database
shadaur.rahman at harbingergroup.com
Mon Aug 22 10:59:30 EDT 2011
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
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;
int b = buffer.Length;
while ((length = myInput.Read(buffer, 0, b)) > 0)
myOutput.Write(buffer, 0, length);
//Close the streams
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,
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
Please help me with your suggestion or code sample.
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.
More information about the Monodroid