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

soLo Lz 41 Reputation points
2023-05-25T06:39:30.8833333+00:00

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.

THIS IS THE CODE:

public void onExportTxt(View view) {

databaseAccess.open();

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();
}

databaseAccess.close();

}

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.
301 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.