Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Feb 2011

    Split the string and make it as list view

    Hi All,

    I am getting data from mysql database using httpconnection in j2me ,It's working fine and also am split the string and made as list view but when displaying list of name is displaying like,first one name displaying well after all names displaying after some space...So what mistake i made please tell me anyone..Am followed this code only
     private String[] split(String original) {
            Vector nodes = new Vector();
            String separator = ":";
            System.out.println("split start...................");
    // Parse nodes into vector
            int index = original.indexOf(separator);
            while (index >= 0) {
                nodes.addElement(original.substring(0, index));
                original = original.substring(index + separator.length());
                index = original.indexOf(separator);
    // Get the last node
    // Create splitted string array
            String[] output = new String[nodes.size()];
            if (nodes.size() > 0) {
                for (int loop = 0; loop < nodes.size(); loop++) {
                    output[loop] = (String) nodes.elementAt(loop);
                    mjkl = output[loop].toString();
                        listview = new List(nameaddtoVector);
            return output;

  2. #2
    Nokia Developer Expert
    Join Date
    Aug 2011

    Re: Split the string and make it as list view

    Hi Murugan,

    This seems to be more an issue related to the content of the strings you are fetching from the database. Code-wise, what you have provided can successfully store each separate string split by a given character (in your case the colon character) in the vector "nodes" and the string array "output". When I test it for example with the string "a:b:c:d:e:f" I get a correct initialization of both the vector and the String array variables.
    Please note though that you need to modify the code a bit, if you want to display the items as a List on the phone (the last three lines before your System.out.println will not work for this purpose). You can take a look at the link below for more information regarding Lists and its usage:


    You could try to further evaluate each String that you get into your vector, depending on your database and its contents, so that for example, you remove any additional non alphabetical or non numerical characters from it, such as spaces or the return character.
    Last edited by skalogir; 2011-10-11 at 14:15.

Similar Threads

  1. how to make it list view using lwuit
    By murugacse4 in forum Mobile Java General
    Replies: 5
    Last Post: 2011-06-30, 08:11
  2. Carbide.vs - why not make it open source and let the community support it
    By chall3ng3r in forum Tools and SDK Feedback (Closed)
    Replies: 0
    Last Post: 2009-03-16, 19:34
  3. Replies: 9
    Last Post: 2008-03-06, 20:35
  4. Replies: 17
    Last Post: 2007-02-19, 11:21
  5. Replies: 6
    Last Post: 2006-04-18, 10:27

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts