I have this method. The problem is that in Android studio the excel path doesn’t exist, but if I use the code in IntelliJ it works perfectly fine. Please help me to understand this issue.
I have this in manifest too:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
tools:ignore="ScopedStorage" />
private static String findRow(String cellContent) throws IOException {
String excelPath="C:\\Users\\mely\\AndroidStudioProjects\\exportingfile.xlsx";
FileInputStream inputStream=new FileInputStream(excelPath);
XSSFWorkbook workbook=new XSSFWorkbook(inputStream);
XSSFSheet sheet=workbook.getSheetAt(0);
for (Row row : sheet) {
for (Cell cell : row) {
if (cell.getRichStringCellValue().getString().trim().equals(cellContent)) {
return sheet.getRow(row.getRowNum()).getCell(9).toString();
}
}
}
return "";
} ```
>Solution :
="C:\Users\mely\AndroidStudioProjects\exportingfile.xlsx"
C: is a partition on a hard disk on a Windows PC.
It is not a valid storage path on an Android device.
Your app on an Android device has no access to files on a Windows PC.
Not to your PC, not to mines.