0

I am trying to write an application that adds data to an exsiting spreadsheet on sdcard.

I am having a problem when i try to create a Writable workbook:

outputWorkbook = Workbook.createWorkbook(outputWorkbookFile,inputWorkbook);

I get the error in Logcat in Eclipse:

04-05 13:29:54.809: W/System.err(32653): java.io.FileNotFoundException: /mnt/sdcard/Dev/Spreadsheets/in.xls (Permission denied)

I can read the input file and get the contents of a cell, i can instanciate a Writable workbook or instanciate an input workbook, but not both.

private void doStuff() {
    File directory = Environment.getExternalStorageDirectory();
    inputWorkbookFile = new File(directory + "/Dev/Spreadsheets/in.xls");
    outputWorkbookFile = new File(directory + "/Dev/Spreadsheets/out.xls");

    try {

        // Put data into an array for easier iteration
        double data[];
        data = new double[7];
        data[0] = income;
        data[1] = diesel;
        data[2] = carHire;
        data[3] = radio;
        data[5] = 0;
        data[6] = itemCost;

        inputWorkbook = Workbook.getWorkbook(inputWorkbookFile);
        Log.e("Testing", "Opened workbook");

        if (isExternalStorageAvailable() && isExternalStorageReadable()) {
            Log.e("Testing", "storage readable and available");
            outputWorkbook = Workbook.createWorkbook(outputWorkbookFile,
                    inputWorkbook);
        }
4

1 回答 1

0

您需要在您的 AndroidManifest uses-permission标签中声明权限android.permission.WRITE_EXTERNAL_STORAGE

于 2012-04-05T13:07:40.113 回答