Dear all,
I have developed a small application in order to format the scanned data. At the end of process, the data are stored in the text file.
I would like save this text file into a folder for that this can be loaded from PC when the TC20 is connected by USB at the PC.
If I use the code proposed by Android, it's not working.
Can you indicate to me, how to do to store my text file in the external storage ?
public boolean write(String dirType, String fileName, String data){
boolean result = false;
if (isOpen){
String path = Environment.getExternalStoragePublicDirectory(dirType).getAbsolutePath();
Log.d(Startup.LOG_TAG,"External storage write path : " + path);
try{
File file = new File(dirType, fileName);
FileWriter fileWriter = new FileWriter(file);
fileWriter.write(data);
fileWriter.flush();
fileWriter.close();
result = true;
} catch (IOException e){}
}
return result;
}
Many thanks,
Serge !
1 Replies
Hi, I do something similar in my location logging application, I suggest you take a look at that: Location-Logger/Storage.java at master · darryncampbell/Location-Logger · GitHub (it is logging locations rather than scanning barcodes but you get the idea)
Thanks,
Darryn.