I am trying to develop an application where I want to pick only .xls/.xlsx file and I want to read the data from it..how should I achieve it?
I wrote code below ..but it allows me to pick up all type of data.`
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btnpurchase=(Button)findViewById(R.id.btnpurchase);
btnsales=(Button)findViewById(R.id.btnsales);
btnpurchase.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("application/xlsx");
startActivityForResult(intent, 7);
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
switch(requestCode){
case 7:
if(resultCode==RESULT_OK){
String PathHolder = data.getData().getPath();
Toast.makeText(MainActivity.this, PathHolder , Toast.LENGTH_LONG).show();
}
break;
}
}