java - 手机sd卡连接电脑看不到文件

标签 java android

我从 android 创建了一个 excel 文件,当我将手机连接到计算机时,然后在计算机中我无法看到该文件。这是为什么?

    Workbook wb = new HSSFWorkbook();
    Cell c = null;

    //Cell style for header row
    CellStyle cs = wb.createCellStyle();

    //New Sheet
    Sheet sheet1 = null;
    sheet1 = wb.createSheet("Meter Readings");

    // Generate column headings
    Row row = sheet1.createRow(1);

    c = row.createCell(0);
    c.setCellValue("Flat Number");
    c.setCellStyle(cs);

    sheet1.setColumnWidth(0, (15 * 200));

    // Create a path where we will place our List of objects on external storage
    File file = new File(context.getExternalFilesDir(null),fileName);
    FileOutputStream os = null;

    try {
        os = new FileOutputStream(file);
        wb.write(os);
        Log.w("FileUtils", "Writing file" + file);
        success = true;
        //os.close();
    } catch (IOException e) {
        Log.w("FileUtils", "Error writing " + file, e);
    } catch (Exception e) {
        Log.w("FileUtils", "Failed to save file", e);
    } finally {
        try {
            if (null != os) {
                os.close();
            }
        } catch (Exception ex) {
        }
    }

最佳答案

您需要重新启动手机或重新连接到您的电脑。

关于java - 手机sd卡连接电脑看不到文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45729284/

相关文章:

java - 如何解压我在 Android 8.1 rom(基于 aosp)中找到的 system.new.dat.br 文件

java - 如何修改 JTextField 以屏蔽字符而不使用 JPasswordField 因此

java - Runnable 使用 ExecutorService 和 BlockingQueue 锁定(停放)

android - 将项目导入Android Studio

android - 如何在Android中的套接字上实现音频调用

php - 来自 WooCommerce REST API 的 "cannot list resources"错误

java - 什么是泛型方法,在这种情况下 <T> 是如何绑定(bind)的?

java - 为什么这个 if 语句测试不起作用?

android - 设置Android模拟器的IP地址

android - 创建未命名为 HelloWorld 的 phonegap 项目