Android打开TXT文件

       super.onCreate(savedInstanceState);
        setContentView(R.layout.main);


        Button button = (Button) this.findViewById(R.id.button);
        button.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {

                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.addCategory(Intent.CATEGORY_DEFAULT);
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
 		Uri uri = Uri.fromFile(new File("/data/data/com.example/files/test.txt"));
                intent.setDataAndType(uri,   "text/plain");
                startActivity(intent);

            }
        });
 

猜你喜欢

转载自ppgl1988.iteye.com/blog/1762793