2011-04-28 9 views
0
내가 전체 다운로드 후 내 목록보기를 업데이트 할

를 새로 고침하지만 나에게 널 포인터 예외가

 
try { 
        URL url = new URL(GlobalVariable.Getstr()); 
        HttpURLConnection c = (HttpURLConnection) url.openConnection(); 
        c.setRequestMethod("GET"); 
        c.setDoOutput(true); 
        c.connect(); 
         int lenghtOfFile = c.getContentLength(); 
         Log.d("ANDRO_ASYNC", "Lenght of file: " + lenghtOfFile); 
        String PATH = Environment.getExternalStorageDirectory() 
          + "/download/"; 
        Log.v(LOG_TAG, "PATH: " + PATH); 
        File file = new File(PATH); 
        file.mkdirs(); 

        // String fileName = "workTest.mp3"; 
        String fileName = GlobalVariable.Getstrpath().toString(); 

        File outputFile = new File(file, fileName); 
        FileOutputStream fos = new FileOutputStream(outputFile); 

        InputStream is = c.getInputStream(); 

        byte[] buffer = new byte[1024]; 
//     int len1 = 0; 
        long total = 0; 
//     while ((len1 = is.read(buffer)) != -1) { 
//      total += len1; 
//      publishProgress(""+(int)((total*100)/lenghtOfFile)); 
//      fos.write(buffer, 0, len1); 
//     
        while ((count = is.read(buffer)) != -1) { 
          total += count; 
          publishProgress(""+(int)((total*100)/lenghtOfFile)); 
          fos.write(buffer, 0, len1); 

        } 
        fos.close(); 
        is.close(); 
//     ArrayAdapter aa=new ArrayAdapter(FindFilesByType.this, android.R.layout.test_list_item,Ringtones); 
//     aa.setNotifyOnChange(true); 
//     lv1.setAdapter(aa); 
        try{ 

         ((ArrayAdapter) lv1.getAdapter()).notifyDataSetChanged(); 

       //  adapter.notifyDataSetChanged(); 




        } 
        catch (Exception e) { 
         Log.i(LOG_TAG, "Error: " + e.toString()); 
        } 



에서 내가

04-28 15:56:17.198: INFO/app(624): Error: java.lang.NullPointerException

무엇입니까 당으로 내 코드는 Nullpointer 예외를 제공합니다

무엇이 잘못 되었나요?

미리 감사드립니다.

+0

이 = 새로운 ArrayAdapter와 (FindFilesByType.this 방법 ArrayAdapter와에게 android.R.layout.test_list_item을 어댑터를 만들어 내 배열 어댑터입니다 ..이

는 희망이 도움이 참조 , 벨소리); \t \t \t \t this.lv1.setAdapter (adapter); – Android

답변

1

어느 라인 예외가 오는가.

notifyDataSetChanged(); 메서드가 lvl.getAdapter()가 아닌입니다. notifyDataSetChanged();

편집 :notifydatasetChange

+0

시도해 보셨습니까 aa.notifyDataSetChanged(); 직접. – Udaykiran

+0

lvl.setAdapter (aa) 목록 표시 .. ..? 데이터 추가가 null이 아닙니다. – Udaykiran

+0

위의 편집 된 링크를 확인하십시오 ... – Udaykiran

관련 문제