2016-03-01 49 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讀取文件 –

相關問題