Juhu, I had the same problem this weekend. My DB has a size of 11 MB and I got a Java.IO.IOException, when I have tried to use AssesManager to transport the DB to my device. There seems to be that the Asset Manager has a problem with greater files (I don't figure out the exact size. sorry!) - Anyway, my solution was, that I declared the DB in my project as embedded resource and used the .NET mechanism to get it out via the Assembly.GetManifestResourceStream to be able to store it in the file system of the Android phone. The only problem with this solution is the size of the assembly, it will be increased by the size of the embedded DB. This may increase the load time for the assembly. You maybe compress the DB with gzipstream before embed it and decompress it, when you write it into the device. Another possible solution could be, to put the DB as embedded resource in a separate assembly, which you load, when it is necessary and the get the DB out of them (Only an idea, I don't have test this approach yet). I hope this will help. Andreas > Date: Mon, 22 Aug 2011 07:59:30 -0700 > From: [email protected] > To: [email protected] > Subject: [mono-android] Error while copying SQLite database > > 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
_______________________________________________ Monodroid mailing list [email protected] UNSUBSCRIBE INFORMATION: http://lists.ximian.com/mailman/listinfo/monodroid
