0
나는 사용자에게 보여줄 pdf 파일을 다운로드 한 후 다운로드 할 수있는 listview가 있습니다. 하지만 내 logcat에 오류가 발생하여 앱이 제대로 작동하지 않습니다. 포럼 및 다른 stackoverflow 솔루션을 읽었지만 내 문제가 해결되지 않습니다. 미리 답변 해 주셔서 감사합니다.안드로이드 쓰기 실패 : ENOSPC (장치에 남은 공간 없음)
내 로그 캣 오류 :
05-24 07:31:52.306: W/System.err(1003): java.io.IOException: write failed: ENOSPC (No space left on device)
05-24 07:31:52.356: W/System.err(1003): at libcore.io.IoBridge.write(IoBridge.java:462)
05-24 07:31:52.605: W/System.err(1003): at java.io.FileOutputStream.write(FileOutputStream.java:187)
05-24 07:31:52.675: W/System.err(1003): at com.example.impresainforma.GiornaliActivity.downloadURL(GiornaliActivity.java:108)
05-24 07:31:52.775: W/System.err(1003): at com.example.impresainforma.GiornaliActivity$LoadGiornale.doInBackground(GiornaliActivity.java:74)
05-24 07:31:52.801: W/System.err(1003): at com.example.impresainforma.GiornaliActivity$LoadGiornale.doInBackground(GiornaliActivity.java:1)
05-24 07:31:52.856: W/System.err(1003): at android.os.AsyncTask$2.call(AsyncTask.java:287)
05-24 07:31:52.906: W/System.err(1003): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
05-24 07:31:52.916: W/System.err(1003): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
05-24 07:31:52.996: W/System.err(1003): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
05-24 07:31:53.006: W/System.err(1003): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
05-24 07:31:53.006: W/System.err(1003): at java.lang.Thread.run(Thread.java:856)
05-24 07:31:53.006: W/System.err(1003): Caused by: libcore.io.ErrnoException: write failed: ENOSPC (No space left on device)
05-24 07:31:53.016: W/System.err(1003): at libcore.io.Posix.writeBytes(Native Method)
05-24 07:31:53.016: W/System.err(1003): at libcore.io.Posix.write(Posix.java:187)
05-24 07:31:53.046: W/System.err(1003): at libcore.io.BlockGuardOs.write(BlockGuardOs.java:197)
05-24 07:31:53.186: W/System.err(1003): at libcore.io.IoBridge.write(IoBridge.java:457)
05-24 07:31:53.186: W/System.err(1003): ... 10 more
05-24 07:31:53.376: A/libc(1003): Fatal signal 11 (SIGSEGV) at 0x000005d0 (code=1), thread 1003 (.impresainforma)
나는
public class GiornaliActivity extends Activity {
private Document m_doc = new Document();
private PDFViewer m_vPDF = null;
public static String dest = null;
public static boolean pdf_downloadable = true;
private Uri linkuri;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = getIntent();
linkuri = intent.getData();
if (isOnline()) {
Global.Init(this);
Global.def_view=2;
new LoadGiornale().execute();
} else {
Toast.makeText(getApplicationContext(),
"Nessuna connessione di rete disponibile.",
Toast.LENGTH_LONG).show();
finish();
}
}
private class LoadGiornale extends AsyncTask<String, Void, String> {
Dialog progress;
protected void onPreExecute() {
super.onPreExecute();
progress = ProgressDialog.show(GiornaliActivity.this, "Caricamento giornale", "Attendere...");
}
@Override
protected String doInBackground(String... arg0) {
try {
if (pdf_downloadable) {
URL url = new URL(linkuri.toString());
dest = downloadURL(url, "mypdf.pdf");
pdf_downloadable = false;
}
} catch (Exception e) {
e.printStackTrace();
}
return dest;
}
protected void onPostExecute(String result) {
super.onPostExecute(result);
progress.dismiss();
runOnUiThread(new Runnable() {
public void run() {
m_doc.Open(dest, null);
m_vPDF = new PDFViewer(GiornaliActivity.this);
m_vPDF.Open(0, m_doc);
setContentView(m_vPDF);
}
});
}
}
public String downloadURL(URL url, String fileName) throws IOException {
String destination = null;
try {
destination = Environment.getExternalStorageDirectory() + "/"
+ fileName;
InputStream input = new BufferedInputStream(url.openStream());
OutputStream output = new FileOutputStream(destination);
byte buffer[] = new byte[1024];
int bytes = 0;
while ((bytes = input.read(buffer)) != -1) {
output.write(buffer, 0, bytes);
}
output.flush();
output.close();
input.close();
}
catch(MalformedURLException e) {
e.printStackTrace();
}
catch(IOException e) {
e.printStackTrace();
}
catch (Exception e) {
e.printStackTrace();
}
return destination;
}
@Override
protected void onDestroy() {
if (GiornaliActivity.dest != null) {
File delFile = new File(GiornaliActivity.dest);
delFile.delete();
pdf_downloadable = true;
Global.RemoveTmp();
}
super.onDestroy();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
public boolean isOnline() {
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo netInfo = cm.getActiveNetworkInfo();
if (netInfo != null && netInfo.isConnectedOrConnecting()) {
return true;
}
return false;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
Intent intent = new Intent(this, CustomizedListView.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}
디스크 공간이 부족한 것 같습니다. – CommonsWare
좋습니다! 내 응용 프로그램을 옵션 -sdcard 옵션으로 실행했지만 사용 된 크기는 매우 작았습니다. 나는 크기를 늘렸고 지금은 아주 잘 작동합니다. 감사합니다 @ CommonSWare – davideagostini