Aufrufen eines Dateipfads aus dem Android Workspace-Ordner

Grundsätzlich habe ich mit der rechten Maustaste auf meinen Projektnamen geklickt und erfolgreich einen neuen Ordner namens pdfs erstellt. Ich möchte hier einige PDF-Dateien vorab laden. Wie würde ich diesen Pfad / somepdffile.pdf aus meiner Hauptaktivitätsklasse aufrufen?

import java.io.File;

import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

public class FullscreenActivity extends Activity {

 @Override
 public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_fullscreen);

  Button button = (Button) findViewById(R.id.bPressMe);

  button.setOnClickListener(new OnClickListener() {
   @Override
   public void onClick(View v) {

    File pdfFile = new File(Environment
      .getExternalStorageDirectory(), "pdfs/2pg.pdf");

    try {
     if (pdfFile.exists()) {
      Uri path = Uri.fromFile(pdfFile);
      Intent objIntent = new Intent(Intent.ACTION_VIEW);
      objIntent.setDataAndType(path, "application/pdf");
      objIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
      startActivity(objIntent);
     } else {
      Toast.makeText(FullscreenActivity.this, "File NotFound",
        Toast.LENGTH_SHORT).show();
     }
    } catch (ActivityNotFoundException e) {
     Toast.makeText(FullscreenActivity.this,
       "No Viewer Application Found", Toast.LENGTH_SHORT)
       .show();
    } catch (Exception e) {
     e.printStackTrace();
    }
   }
  });

 }

}

Antworten auf die Frage(3)

Ihre Antwort auf die Frage