I create xls file in java in android using apache poi
. In the file manager of the phone, it is visible, if you connect the file to the PC via the cord, it is not visible. If the phone moves this file somewhere, the PC starts to see it. Like something with the rights, but I can not figure it out.
Module:
public static boolean makeXls(String[][] data) throws IOException { Boolean result = true; Workbook book = new HSSFWorkbook(); Sheet sheet = book.createSheet("Contacts"); // Нумерация начинается с нуля for(int i=0; i<data.length; i++){ Row row = sheet.createRow(i); for(int j=0; j<data[i].length; j++){ Cell cell = row.createCell(j); cell.setCellValue(data[i][j]); } } //Обрабатываем файл String newFname = file; Boolean existFile = true; int i = 1; //Генерируем новое имя файла если такой уже есть while (existFile) { if (new File(newFname + ".xls").exists()) { newFname = file + i; } else existFile = false; i += 1; }; try { FileOutputStream resFile = new FileOutputStream(newFname + ".xls"); book.write(resFile); resFile.flush(); resFile.close(); } catch(Exception e){ System.err.println(e); result = false; } book.close(); File curFile = new File(newFname + ".xls"); curFile.getAbsoluteFile().setReadable(true); curFile.getAbsoluteFile().setWritable(true); System.err.println(curFile.canRead()); System.err.println(curFile.canWrite()); return result; }