tags:

views:

31

answers:

0

here the code for parsing url.. new Thread(new Runnable() { public void run() { try{ Log.v("Start","Thread"); DBF=DocumentBuilderFactory.newInstance();
DB=DBF.newDocumentBuilder();
URL url_val=new URL("http://www.dashfire.com/jackrobie/mobile/allproducts.php"); dom=DB.parse(url_val.openConnection().getInputStream()); elt=dom.getDocumentElement();
NodeList items = elt.getElementsByTagName("product"); for (int i=0;i Log.v(TAG,"Image_97: "+image_97);

                  //where we want to download it from

                  URL url = new URL(image_97);  //http://example.com/image.jpg

                  //open the connection

                  URLConnection ucon = url.openConnection();

                  //buffer the download

                  InputStream is = ucon.getInputStream();

                  BufferedInputStream bis = new BufferedInputStream(is,128);

                  ByteArrayBuffer baf = new ByteArrayBuffer(128);

                  //get the bytes one by one

                  int current = 0;

                  while ((current = bis.read()) != -1) {
                       int aa =0;
                      Log.v("Loop",Integer.toString(aa) );

                          baf.append((byte) current);
                      aa++;

                  }

                  //store the data as a ByteArray

                  //db is a SQLiteDatabase object

// ContentValues dataToInsert = new ContentValues();
//
// dataToInsert.put(TABLE_FIELD,baf.toByteArray()); //
// db.insert(TABLE_NAME, null, dataToInsert);

                       }
                  if (name.equalsIgnoreCase("image_205"))
                   {
                    image_205=property.getFirstChild().getNodeValue();
                       Log.v(TAG,"Image_205: "+image_205);
                   }
                 }try{
                     addevent(name,price,baf.toByteArray());
                 }catch(Exception e)
                 {
                  Log.v(TAG,"error"+e);  
                 }
              }

                 }catch(Exception e){
                Log.v("TAG2","error"+e);     

                 }
            }
          }).start();

2.here the code for addevent private void addevent(String a1,String a2,byte[]a3) {

        ContentValues values = new ContentValues();         
        values.put(JR_Constants.NAME, a1);
        values.put(JR_Constants.PRICE, a2);
        values.put(JR_Constants.IMAGE_97, a3);
    try{
        getContentResolver().insert(JR_Constants.CONTENT_URI, values);
        }catch(Exception e)
        {
            Log.v("Error from db insert",""+e);

        }
  }

when i insert by this the field name gets blank in db