1
내 안드로이드 전화에서 PDF 파일을 가져 오려면 다음 코드를 사용하십시오. 그러나 동일한 기능을 수행하지만 외부 메모리 카드의 pdf 파일 만 제공합니다.안드로이드에서 외부 SD 카드에서 PDF를 읽는 중
plzz 가이드 외부 SD 카드에서 PDF 파일도
public class MainActivity extends Activity {
File path;
ListView list;
static ArrayList<String> pdf_paths=new ArrayList<String>();
static ArrayList<String> pdf_names=new ArrayList<String>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
list=(ListView)findViewById(R.id.listView1);
pdf_paths.clear();
pdf_names.clear();
//Access External storage
path = new File(Environment.getExternalStorageDirectory() + "");
searchFolderRecursive1(path);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, android.R.id.text1, pdf_names);
Log.e("aaaaaaaaaa", ""+pdf_names);
list.setAdapter(adapter);
list.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,long arg3) {
// TODO Auto-generated method stub
String path = pdf_paths.get(arg2);
File file = new File(path);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file), "application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
startActivity(intent);
}
});
}
private static void searchFolderRecursive1(File folder)
{
if (folder != null)
{
if (folder.listFiles() != null)
{
for (File file : folder.listFiles())
{
if (file.isFile())
{
//.pdf files
if(file.getName().contains(".mp3"))
{
Log.e("ooooooooooooo", "path__="+file.getName());
file.getPath();
pdf_names.add(file.getName());
pdf_paths.add(file.getPath());
Log.e("pdf_paths", ""+pdf_names);
}
}
else
{
searchFolderRecursive1(file);
}
}
}
}
}
}
y에는 아무 것도 없습니다. 마이크로 SD 카드를 처리하는 코드. 외부 메모리 만 조사 중입니다. – greenapps
'내가 줬지 만'??? 뭐? – greenapps