How to clear a text file in a directory using android java?

soLo Lz 41 Reputation points

This code will export table tranpbilmonsms to text file tranpbilmonsms.txt. How do you clear the text inside the text file in a directory? text file file must clear first before I inserted the text from the table.. Thank you.


public void onExportTxt(View view) {;

try {

'Insert HERE the code that will clear tranpbilmonssms.txt' databaseAccess.exportToTxt(Environment.getExternalStorageDirectory().getPath() + "/tranpbilmonsms.txt","tranpbilmonsms"); Toast.makeText(this, "Successfully export to txt.", Toast.LENGTH_SHORT).show();

} catch (Exception e) {
	Log.e("Error", e.getMessage());
	Toast.makeText(this, "Failed to export to txt.", Toast.LENGTH_SHORT).show();



Microsoft Intune Android
Microsoft Intune Android
Microsoft Intune: A Microsoft cloud-based management solution that offers mobile device management, mobile application management, and PC management capabilities.Android: An open-source mobile platform based on the Linux kernel, developed by Google, and maintained by the Open Handset Alliance.
109 questions
0 comments No comments
{count} votes