I am developing a crossword application which accepts .puz file as input. I tried the following code in which the application doesn't accept .puz file from default file manager while it accepts the and begins the game when it is sent through third-party file-managers like ES file manager. Is there a way to make it accept the input through default file manager?
public void loadFile(View view){
Intent intent = new Intent(MediaStore.Files.FileColumns.DATA);
intent.setType("*/*");
intent.putExtra("CONTENT_TYPE", "*/*");
intent.addCategory(Intent.CATEGORY_DEFAULT);
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select PUZ file"), 1);
}
//selected file will be processed here
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if(requestCode == 1){
if(resultCode == RESULT_OK){
String path = getPath(data.getData());
if(path!=null&&path.endsWith("puz")) {
try {
PuzzleDatabaseHelper dbHelper = WordsWithCrossesApplication.getDatabaseHelper();
Intent intent = new Intent(Intent.ACTION_EDIT, null, this, PlayActivity.class);
intent.putExtra(PlayActivity.EXTRA_PUZZLE_ID, dbHelper.addPuzzle(new File(path),"dilip","",0));
this.startActivity(intent);
} catch (Exception e) {
}
}
else
Toast.makeText(this, "Invalid Format or Try different File Manager to select file", Toast.LENGTH_SHORT).show();
}
}
}