2016-03-01 44 views
0

我在我的设备中有一个名为test.csv的文件。当我点击该文件打开通过我的app.how设置默认打开(对话框)选项到我的应用程序在Android?如何设置默认打开(对话框)选项到我的android应用程序?

enter image description here

以上是样品dailog.how到我的应用程序添加到列表的对话框?

+0

可能的重复http://stackoverflow.com/questions/9872450/make-your-app-a-default-app-to-open-a-certain-file – Enzokie

+0

@neferpitou我找不到任何正确的解决方案链接,是否有任何示例代码请提供给我。 – Rajesh

+0

[注册为自定义文件类型的默认应用程序]的可能重复(http://stackoverflow.com/questions/3465429/register-to-be-default-app-for-custom-file-type) –

回答

-1

我想你可能想阅读csv文件。你可以得到csv文件路径。所以看看下面的内容。

public static void readCSV(File file) { 
    BufferedReader reader = null; 
    StringBuilder stringBuilder = new StringBuilder(); 
    try { 
     InputStreamReader isr = new InputStreamReader(new FileInputStream(file));// your csv file 
     reader = new BufferedReader(isr); 
     String line = null; // every time read one line 
     while ((line = reader.readLine()) != null) { 
      stringBuilder.append(line); 
      stringBuilder.append("\n"); 
     } 
    } catch (Exception e) { 
     e.printStackTrace(); 
    } finally { 
     try { 
      reader.close(); 
     } catch (IOException e) { 
      e.printStackTrace(); 
     } 
    } 
} 

stringBuilder.toString()是您的csv文件的内容。对不起我的英语不好。

+0

问题没有问如何用Java读取文件 –

相关问题