Skip to content

hsmnzaydn/easy-csv

Repository files navigation

easy-csv

Creates csv file for android

Download

Add it in your root build.gradle at the end of repositories:

allprojects {

repositories {
...
    maven { url 'https://jitpack.io' }
    }
}

Add the dependency

dependencies {
implementation 'com.github.hsmnzaydn:easy-csv:1.0.0'
}

Use Steps

Step 1: Create EasyCsv Object

EasyCsv easyCsv = new EasyCsv(MainActivity.this);

Step 2: Create your headerlist and datalist

List<String> headerList = new ArrayList<>();
headerList.add("Name.Surname.Age-");

List<String> dataList = new ArrayList<>();
dataList.add("Serkan.Ozaydin.23-");

Step 3: Select separators for column and line

easyCsv.setSeparatorColumn(".");
easyCsv.setSeperatorLine("-");

Step 4: Select separators for column and line

/**
* @param fileName Name of the file to be created
* @param WRITE_PERMISSON_REQUEST_CODE EasyCsv request runtime permission for Write permission to user. When user "Accept" or "Decline" for you can handler
*/
easyCsv.createCsvFile(fileName, headerList, dataList WRITE_PERMISSON_REQUEST_CODE, new FileCallback() {
@Override
public void onSuccess(File file) {
}

@Override
public void onFail(String err) {
}
});

License

Copyright 2018 Huseyin Serkan Ozaydin

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.