[android-developers] Re: Share Your Practical Experience to build Android Application with Pre-Populated Database
> Have you developed any android application which is using pre- > populated database (say Size in between 1-5 MB , is size any issue?), > If yes , May you please tell any trick which you used and work best > for you ? Yes I did. 1-5 MB is no issue. Just don't try to copy the db to SDCard. If you do you'll get lots of SQLiteExceptions of all sorts once you go live, sdcards seems to be pretty shaky on some phones. To keep the APK small you might want to zip the pre-populated db (located in the Assets folder). Here's some sample code (_sample_, not fully functional): InputStream input = MyApplication.getContext().getAssets().open(ASSETS_DB); ZipInputStream zipInput = new ZipInputStream(input); ZipEntry zipEntry = zipInput.getNextEntry(); File outPath = new File(destPath); outPath.mkdirs(); File outFile = new File(destFile); outFile.createNewFile(); FileOutputStream output = new FileOutputStream( outFile ); copyFile(zipInput, output)); private boolean copyFile(InputStream in, FileOutputStream out) throws IOException { // transfer bytes from the input to the output byte[] buffer = new byte[4096]; int bytesRead; while ((bytesRead = in.read(buffer))>0){ out.write(buffer, 0, bytesRead); } out.flush(); return sync(out); } > If you developed any android application which gets data from file > rather from database etc ? means initially you thought you might need > to create the database and fill it up as pre-populated database but > such techniques didn't work , so you applied some other techniques - > e.g; you might used xyz file, and your application's business logic > directly read the stuff from file and show on view - rather populating > in database and then read from there ? In other cases I used files to store information. Not because the database wouldn't have done the job but because fast access to the information wasn't as critical as keeping the app as small as possible (and no CursorAdapters were needed to display the information). In this case I used a large zip file as container for many smaller files. Meta information was encoded in the file name. The files itself were compressed using a proprietary compression algorithm which gave much compression ratios than the standard algorithms. It all depends on you specific requirements whether you would use a database or some files in the assets folder. Cheers Emanuel Moecklin 1gravity LLC -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Share Your Practical Experience to build Android Application with Pre-Populated Database
1. Create your database on your desktop or server. 2. Publish your database file at a downloadable URI (http/ftp/ whatever). 3. Have your app download the database to a suitable location. 4. Access your database from the app. Doug On Dec 6, 6:29 am, eSumit wrote: > Have you developed any android application which is using pre- > populated database (say Size in between 1-5 MB , is size any issue?), > If yes , May you please tell any trick which you used and work best > for you ? > > Or > > If you developed any android application which gets data from file > rather from database etc ? means initially you thought you might need > to create the database and fill it up as pre-populated database but > such techniques didn't work , so you applied some other techniques - > e.g; you might used xyz file, and your application's business logic > directly read the stuff from file and show on view - rather populating > in database and then read from there ? > > Please reply IF you have ever done that ? or something which is closed > to solution -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Share Your Practical Experience to build Android Application with Pre-Populated Database
put your database in the assets folder and rename it to something silly to work around the 1 MB size limitation. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Share Your Practical Experience to build Android Application with Pre-Populated Database
Generally, a file is a database. done it. no issues. On Dec 6, 6:29 am, eSumit wrote: > Have you developed any android application which is using pre- > populated database (say Size in between 1-5 MB , is size any issue?), > If yes , May you please tell any trick which you used and work best > for you ? > > Or > > If you developed any android application which gets data from file > rather from database etc ? means initially you thought you might need > to create the database and fill it up as pre-populated database but > such techniques didn't work , so you applied some other techniques - > e.g; you might used xyz file, and your application's business logic > directly read the stuff from file and show on view - rather populating > in database and then read from there ? > > Please reply IF you have ever done that ? or something which is closed > to solution -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en