this codes was from another post : Android open pdf file
this is all my codes in 1 class called openFile.class
package com.test.android;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.net.Uri;
import android.os.Environment;
import java.io.File;
public class openFile {
String namafile ;
public openFile(String namafile){
this.namafile = namafile;
}
File file = new
File(Environment.getExternalStorageDirectory().getAbsolutePath() +"/"+
namafile);
Intent target = new Intent(Intent.ACTION_VIEW);
target.setDataAndType(Uri.fromFile(file),"application/pdf");
target.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
Intent intent = Intent.createChooser(target, "Open File");
try {
startActivity(intent);
} catch (ActivityNotFoundException e) {
// Instruct the user to install a PDF reader here, or something
}
}
any suggestions will be accepted