我的设计中有一个名为 test.csv 的文件。当我单击该文件时,通过我的应用程序打开该文件。如何在 android 中为我的应用程序设置默认打开方式(对话框)选项?
以上是示例dailog。如何将我的应用程序添加到对话框列表?
我的设计中有一个名为 test.csv 的文件。当我单击该文件时,通过我的应用程序打开该文件。如何在 android 中为我的应用程序设置默认打开方式(对话框)选项?
以上是示例dailog。如何将我的应用程序添加到对话框列表?
我想你可能想阅读 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 文件的内容。对不起我的英语不好。