Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"NoSuchMethodError" Exception is thrown while saving to csv #26

Closed
sodiqOladeni opened this issue Oct 15, 2018 · 1 comment
Closed

"NoSuchMethodError" Exception is thrown while saving to csv #26

sodiqOladeni opened this issue Oct 15, 2018 · 1 comment
Assignees

Comments

@sodiqOladeni
Copy link

@osiegmar
Unable to save to csv due to exception, below is my stack trace and my code.
No virtual method toPath()Ljava/nio/file/Path; in class Ljava/io/File;

if (entityList.size() > 0) {

                File storageDir = new File(Environment.getExternalStorageDirectory() + "/"
                        + this.getString(R.string.app_name));

                boolean success = true;
                if (!storageDir.exists()) {
                    success = storageDir.mkdirs();
                }

                if (success) {

// String baseDir = getExternalStorageDirectory().getAbsolutePath();
// String filePath = baseDir + "/" + "Demo.csv";
File file = new File(storageDir, "contacts.csv");
CsvWriter csvWriter = new CsvWriter();
Collection<String[]> data = new ArrayList<>();
for (ContactEntity d : entityList) {
data.add(new String[]{"Name", "Phone Number"});
data.add(new String[]{d.getName(), d.getName()});
}
try {
csvWriter.write(file, StandardCharsets.UTF_8, data);
Log.v(TAG, "csv file created");
} catch (IOException e) {
e.printStackTrace();
}
}else {
Toast.makeText(this, "Directory not exist", Toast.LENGTH_SHORT).show();
}
} else {
Toast.makeText(this, "No data to export csv", Toast.LENGTH_SHORT).show();
}

@osiegmar
Copy link
Owner

I guess, you're using Android, not Java. Please see #3.

@osiegmar osiegmar self-assigned this Oct 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants