• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

issue while importing the csv file to sqlite from google driveit only import file from my device

neha_evm

Lurker
issue while importing the csv file to sqlite from google drive ,it only import file from my device and not import file from other device with using same email id on both devices....and yes file is export properly.there is issue at import end.
here the code

private void proImportCsv(File from){
File dbfile1=getDatabasePath("Project.db");
dbhelper=new DBHelper(getApplicationContext());

try {


File exportDir2 = new File(Environment.getExternalStorageDirectory().getPath(), "");
if (!exportDir2.exists())
{
exportDir2.mkdirs();

}

File file2 = new File(from, "Project.csv");
ContentValues contentValues = new ContentValues();
CSVReader dataRead = new CSVReader(new FileReader(file2));

String[] str = null;

while((str = dataRead.readNext())!=null) {
contentValues.clear();


String date;
try {


contentValues.put(Database.ACCOUNTS_ID, str[0]);
contentValues.put(Database.ACCOUNTS_ACNO, str[1]);
contentValues.put(Database.ACCOUNTS_HOLDERS, str[2]);
contentValues.put(Database.ACCOUNTS_CNO, str[3]);
contentValues.put(Database.ACCOUNTS_BANK, str[4]);
contentValues.put(Database.ACCOUNTS_HOLDERS, str[5]);
contentValues.put(Database.ACCOUNTS_ADDRESS, str[6]);
contentValues.put(Database.ACCOUNTS_IFSC, str[7]);
contentValues.put(Database.ACCOUNTS_MICR, str[8]);
contentValues.put(Database.ACCOUNTS_BALANCE, str[9]);
contentValues.put(Database.ACCOUNTS_REMARKS, str[10]);



}
catch (Exception e) {
}

SQLiteDatabase db= dbhelper.getWritableDatabase();
db.insert(Database.ACCOUNTS_TABLE_NAME,null,contentValues);

db.close();
}
dataRead.close();
} catch (Exception e) {
Log.e("TAG",e.toString());
}}
 
Back
Top Bottom