I've been trying to work with a CSV file in android, but I must be doing something badly wrong.
It seems to me that I am missing something key within the android WAY that would allow me to do what I'm trying to do. Logically, other apps need pre-built databases, whether they download it on start or they import a CSV file into the db on creation. I keep thinking that this should not be as hard as it is, but I feel like I am banging my head against the wall here. I've tried using the OpenCSV (http://opencsv.sourceforge.net/) library to read the file into a List of Strings[], and my app crashes. I've tried using FileInputStream to read lines from the file, and the app crashes. Now there is clearly something that I am missing that would make all this pretty simple, but as it stands, I am extremely frustrated. I don't want to give up on Android, but this is making it really hard not to just walk away. If anyone can post sample code of reading a CSV into a List<String[]> type object (so that each line is a String[] with each comma separated value being an element in the String[] array, I'd appreciate it. That of course may be a bit much. If you can just show me the basic code of writing how to get teh lines from a file called foo.csv located in either /res/raw OR /assets I'd appreciate it. I don't even care so much about the code as much as understanding what the process is (code is important for that understanding, but not the only thing). I am so lost that it's painful. Thanks. Ben On Mon, Mar 8, 2010 at 4:00 PM, Adrian Vintu <[email protected]> wrote: > You should probably also zip the CSV file. You have built in un/zip > capabilities on Android. > > > BR, > Adrian Vintu > > http://adrianvintu.com > > > On Mon, Mar 8, 2010 at 8:08 PM, Ben Orchard <[email protected]> wrote: > >> I have a few different apps that I need to use dbs with. One has a DB >> (public domain) that is 4.3 MB. Either downloading it after creation OR >> packing it in is going to cause problems. >> >> All my other dbs are much smaller. I'm guessing, however, that >> downloading a CSV then packing the db on the first run might be the best way >> to go. >> >> Thanks >> >> On Sun, Mar 7, 2010 at 7:50 AM, Adrian Vintu <[email protected]>wrote: >> >>> How much data is your DB going to hold? Remember, you cannot force the >>> user to download 10M of apk over GPRS. I also think there probably is a >>> limit of the apk size on the Android Market. >>> >>> Dictionary applications, for example, hold ~30MB in the database. The >>> applications have a custom built in database downloader. So they do not pack >>> these huge databases in the apk, but rather download the database on first >>> use. >>> >>> Another example would be packing in the apk a CSV file containing >>> NAME|ADDRESS|PHONE. You can then, at first use of the app, create an sqlite >>> database from importing the data from the CSV file. >>> >>> I think you can play around to see what scenario fits you best. >>> >>> >>> BR, >>> Adrian Vintu >>> >>> http://adrianvintu.com >>> >>> >>> On Sun, Mar 7, 2010 at 5:51 AM, Ben Orchard <[email protected]>wrote: >>> >>>> Hey, I wanted to say thanks for the information. >>>> >>>> Let me ask one more thing: I have a large amount of data that I want to >>>> use in conjunction with my app. In my mind it seems more efficient to use >>>> a >>>> db to store this data, but packing the db in android seems..odd. I think >>>> it >>>> might be easier to pack the db using a better tool, then just access the >>>> pre-packed db in the app. >>>> >>>> Any thoughts on this? >>>> >>>> Thanks again. >>>> >>>> On Sat, Mar 6, 2010 at 3:04 PM, Adrian Vintu <[email protected]>wrote: >>>> >>>>> Yes to all :) >>>>> >>>>> Typically, you will pack your DB in the Android project and unpack it >>>>> on the device. >>>>> >>>>> BR, >>>>> Adrian Vintu >>>>> >>>>> http://adrianvintu.com >>>>> >>>>> >>>>> On Thu, Mar 4, 2010 at 7:36 PM, Ben Orchard <[email protected]>wrote: >>>>> >>>>>> Let me ask this, since I suspect it's the question that was on the >>>>>> mind of the submitter, and it's on mine as well. >>>>>> >>>>>> Can I create an sqlite db on my computer, populate then use that as >>>>>> the main data source for my app? That's the question that I think is >>>>>> most >>>>>> pressing. If the answer is yes, then is it as simple as moving the file >>>>>> (I >>>>>> don't know the sqlite extension) to the resources folder in your project? >>>>>> >>>>>> Thanks, Ben >>>>>> >>>>>> >>>>>> On Wed, Mar 3, 2010 at 2:10 AM, Maxood <[email protected]> wrote: >>>>>> >>>>>>> Here are your required answers: >>>>>>> >>>>>>> Q.Which database i can use ? >>>>>>> A. SQLite. You can download it free from www.sqlite.org >>>>>>> >>>>>>> Q. What should be connection string ? >>>>>>> A. You can make a database adapter class instead. Go though these >>>>>>> links >>>>>>> >>>>>>> http://developer.android.com/reference/android/database/sqlite/package-summary.html >>>>>>> http://www.devx.com/wireless/Article/40842/1954 >>>>>>> >>>>>>> Q. How i can deploy queries ? >>>>>>> A. You can write queries in your class using cursors >>>>>>> >>>>>>> Q. How i can parse recordsets etc ? >>>>>>> A. Look into the Android SQLite API: >>>>>>> >>>>>>> http://developer.android.com/reference/android/database/sqlite/package-summary.html >>>>>>> >>>>>>> Hope this helps. >>>>>>> >>>>>>> Android Developer, >>>>>>> Maqsood >>>>>>> http://www.twitter.com/maxood >>>>>>> On Feb 23, 11:51 pm, Harminder Singh <[email protected]> wrote: >>>>>>> > Hello, >>>>>>> > >>>>>>> > I am newbie to Android application development. Can anybody help me >>>>>>> > about to set up database related applications. >>>>>>> > I have many questions into mind like: >>>>>>> > Which database i can use ? >>>>>>> > How i can use that ? >>>>>>> > What should be connection string ? >>>>>>> > How i can deploy queries ? >>>>>>> > How i can parse recordsets etc ? >>>>>>> > >>>>>>> > Seeking your valuable comments >>>>>>> > >>>>>>> > Thank in Advance >>>>>>> > Harminder >>>>>>> >>>>>>> -- >>>>>>> You received this message because you are subscribed to the Google >>>>>>> Groups "Android Beginners" group. >>>>>>> >>>>>>> NEW! Try asking and tagging your question on Stack Overflow at >>>>>>> http://stackoverflow.com/questions/tagged/android >>>>>>> >>>>>>> To unsubscribe from this group, send email to >>>>>>> [email protected]<android-beginners%[email protected]> >>>>>>> For more options, visit this group at >>>>>>> http://groups.google.com/group/android-beginners?hl=en >>>>>>> >>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> I have no bit of wisdom to include as a signature. >>>>>> >>>>>> -- >>>>>> You received this message because you are subscribed to the Google >>>>>> Groups "Android Beginners" group. >>>>>> >>>>>> NEW! Try asking and tagging your question on Stack Overflow at >>>>>> http://stackoverflow.com/questions/tagged/android >>>>>> >>>>>> To unsubscribe from this group, send email to >>>>>> [email protected]<android-beginners%[email protected]> >>>>>> For more options, visit this group at >>>>>> http://groups.google.com/group/android-beginners?hl=en >>>>>> >>>>> >>>>> -- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "Android Beginners" group. >>>>> >>>>> NEW! Try asking and tagging your question on Stack Overflow at >>>>> http://stackoverflow.com/questions/tagged/android >>>>> >>>>> To unsubscribe from this group, send email to >>>>> [email protected]<android-beginners%[email protected]> >>>>> For more options, visit this group at >>>>> http://groups.google.com/group/android-beginners?hl=en >>>>> >>>> >>>> >>>> >>>> -- >>>> I have no bit of wisdom to include as a signature. >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Android Beginners" group. >>>> >>>> NEW! Try asking and tagging your question on Stack Overflow at >>>> http://stackoverflow.com/questions/tagged/android >>>> >>>> To unsubscribe from this group, send email to >>>> [email protected]<android-beginners%[email protected]> >>>> For more options, visit this group at >>>> http://groups.google.com/group/android-beginners?hl=en >>>> >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Android Beginners" group. >>> >>> NEW! Try asking and tagging your question on Stack Overflow at >>> http://stackoverflow.com/questions/tagged/android >>> >>> To unsubscribe from this group, send email to >>> [email protected]<android-beginners%[email protected]> >>> For more options, visit this group at >>> http://groups.google.com/group/android-beginners?hl=en >>> >> >> >> >> -- >> I have no bit of wisdom to include as a signature. >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Android Beginners" group. >> >> NEW! Try asking and tagging your question on Stack Overflow at >> http://stackoverflow.com/questions/tagged/android >> >> To unsubscribe from this group, send email to >> [email protected]<android-beginners%[email protected]> >> For more options, visit this group at >> http://groups.google.com/group/android-beginners?hl=en >> > > -- > You received this message because you are subscribed to the Google > Groups "Android Beginners" group. > > NEW! Try asking and tagging your question on Stack Overflow at > http://stackoverflow.com/questions/tagged/android > > To unsubscribe from this group, send email to > [email protected]<android-beginners%[email protected]> > For more options, visit this group at > http://groups.google.com/group/android-beginners?hl=en > -- I have no bit of wisdom to include as a signature. -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en To unsubscribe from this group, send email to android-beginners+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.

