get the content of android mobile
i would like to read the content of mobile like directories with sub directories as well as files which are available in android phone.
i have implemented an application for get the content of android phone as follows
Intent intent = new Intent();
intent.setAction(Intent.ACTION_PICK);
// Browse in the following folder.
Uri startDir = Uri.fromFile(new File("/sdcard/"));
// Files开发者_StackOverflow社区 and directories
intent.setDataAndType(startDir, "vnd.android.cursor.dir/lysesoft.andexplorer.file");
// Optional filtering on file extension.
intent.putExtra("browser_filter_extension_whitelist", "*.xml,*.txt,*.jpg,*.mp3,*.zip");
// Title
intent.putExtra("explorer_title", "Open File...");
// Optional font scale
intent.putExtra("browser_list_fontscale", "120%");
// Optional 0=simple list, 1 = list with filename and size, 2 = list with filename, size and date.
intent.putExtra("browser_list_layout", "2");
startActivityForResult(intent, OPEN_FILE_REQUEST);
if i use above shown way i am getting force close error as:
05-26 18:20:02.917: ERROR/AndroidRuntime(26867): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.PICK dat=file:///sdcard typ=vnd.android.cursor.dir/lysesoft.andexplorer.file (has extras) }
here how can i resolve the force close error issue? is there any another way to get the content of android phone?
please any body help me
thanks in advance
Try
final File dir = context.getFilesDir();
for (final File file : dir.listFiles()) {
...
}
and
final File dir = new File("/sdcard");
for(final File file : dir.listFiles()){
...
}
Try the following code.
Intent intent = new Intent();
intent.setAction(Intent.ACTION_PICK);
// Browse in the following folder.
Uri startDir = Uri.parse(Environment.getExternalStorageDirectory().getAbsolutePath());
// Files and directories
intent.setDataAndType(startDir, "vnd.android.cursor.dir/lysesoft.andexplorer.file");
// Optional filtering on file extension.
intent.putExtra("browser_filter_extension_whitelist", "*.xml,*.txt,*.jpg,*.mp3,*.zip");
// Title
intent.putExtra("explorer_title", "Open File...");
// Optional font scale
intent.putExtra("browser_list_fontscale", "120%");
// Optional 0=simple list, 1 = list with filename and size, 2 = list with filename, size and date.
intent.putExtra("browser_list_layout", "2");
startActivityForResult(intent, OPEN_FILE_REQUEST);
Thanks Deepak
You may not have AndExplorer (lysesoft.andexplorer.file) installed on your system.
- Dropbox
- Hit the Menu button
- Choose Upload here
精彩评论