private void showFileChooser() {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("*/*");
intent.addCategory(Intent.CATEGORY_OPENABLE); try {
startActivityForResult(
Intent.createChooser(intent, "Select a txt File to import(one phone one line)"),
FILE_SELECT_CODE);
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(this, "Please install a File Manager.",
Toast.LENGTH_SHORT).show();
}
}      启动文件选择的intent

解决方案 »

  1.   

    //import phone numbers  is :123456789   这句话输出了没有?????
    如果这句输出了,且后面号码正确,说明文件读取正常,否则就是文件读取问题,与edittext无关
    下面的设置我看是没有问题的,如果有问题,把contact_list的布局内容弄出来
      

  2.   

    你好,日志显示的是文本文件的内容,就是界面没有更新,edittext只是一个普通的控件,我是可以手动编辑并保存的
      

  3.   

    不用管输出的是啥,
    //import phone numbers  is :123456789
    只要这句话没输出,说明没到这一步,极可能是
    resultCode == RESULT_OK
    根到就没到这个条件里,与edittext一点关系都没有
    先理清问题所在是解决问题的关键
      

  4.   


    你好,多谢你的回复,results_ok下面的是有打印的,把文本文件都打印出来了。
      

  5.   


    布局文件:
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >    <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:paddingTop="20dp"
            android:text="Set contact list(separate by ;)"
            android:textSize="20sp" />    <EditText
            android:id="@+id/contact_list"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:hint="@string/hint"
            android:minLines="3"
            android:text="" />    <Button
            android:id="@+id/txt_select"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="20dp"
            android:layout_marginTop="20dp"
            android:text="Import from file" />    <Button
            android:id="@+id/save_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/save_button" /></LinearLayout>
      

  6.   

    解决了,是由于我再resume中重新获取peference进行显示,而在onActivityResults()中没有提交,导致结果没有保存,resume是在它之后执行的,多谢大家的帮助!