How to convert and send text in Sketchware as text (.txt) file?

We know that it is not possible to add permissions in Sketchware, and since saving any file requires permissions​ to WRITE EXTERNAL STORAGE, it cannot be done in Sketchware.

But I have found a way to create text (.txt) files in Sketchware from contents of Edittext or Textview, and then share the file using intent. The file can also be saved directly to external storage by using ES File Explorer.

Follow the steps below to create and send text files from your Sketchware App.

1. Insert two Edittext widgets, say edittext1 and edittext2, in VIEW area of your sketchware project. One is for title and other for text.

2. Insert a Button and change it's text to 'Send'.

3. In LOGIC area​ of your project, in onButtonClick event, use add source directly block, and write the following code:

try { myFile = new + "/" + edittext1.getText() + ".txt"); myFile.createNewFile(); fOut = new; myOutWriter = new;

Intent email = new Intent(Intent.ACTION_SEND);
email.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new + "/" + edittext1.getText() + ".txt")));
startActivity(Intent.createChooser(email, "Send: Text File"));

Toast.makeText(getBaseContext(), "File Created with name" + edittext1.getText() + ".txt", Toast.LENGTH_SHORT).show();

catch (Exception e) {
Toast.makeText(getBaseContext(), e.getMessage(), Toast.LENGTH_SHORT).show();

Note that in this code we get text from edittext1 and set it as file name, and we set text from edittext2 as file contents.

The code above creates a text file in external cache (which doesn't need permissions to write), and then shares the created text file using intent.

4. Save and run the project. You will be able to share the contents of edittext2 field as text file. And if you have ES file explorer, you can save the text file directly to sdcard.

Here is a video on how I found the code:


  1. Thank you sir for teaching us regarding sketch ware...
    We need more these kind of posts.

  2. Thanks for sharing this information, really appreciate it. Would be great if we could later copy the vscroll as an image and do the same :). Have a great day

  3. HttpURLConnection connection = null;
    DataOutputStream outputStream = null;
    DataInputStream inputStream = null;
    String pathToOurFile = "/data/file_t";
    String urlServer = "";
    String lineEnd = "\r\n";
    String twoHyphens = "--";
    String boundary = "*****";

    int bytesRead, bytesAvailable, bufferSize;
    byte[] buffer;
    int maxBufferSize = 1*1024*1024;

    { fileInputStream = new );

    URL url = new URL(urlServer);
    connection = (HttpURLConnection) url.openConnection();

    // Allow Inputs & Outputs.

    // Set HTTP method to POST.

    connection.setRequestProperty("Connection", "Keep-Alive");
    connection.setRequestProperty("Content-Type", "multipart/form-data;boundary="+boundary); = new DataOutputStream( connection.getOutputStream() ); + boundary + lineEnd); form-data() + "/" + edittext1.getText() + ".txt");;

    bytesAvailable = fileInputStream.available();
    bufferSize = Math.min(bytesAvailable, maxBufferSize);
    buffer = new byte[bufferSize];

    // Read file
    bytesRead =, 0, bufferSize);

    while (bytesRead > 0)
    outputStream.write(buffer, 0, bufferSize);
    bytesAvailable = fileInputStream.available();
    bufferSize = Math.min(bytesAvailable, maxBufferSize);
    bytesRead =, 0, bufferSize);

    outputStream.writeBytes(twoHyphens + boundary + twoHyphens + lineEnd);

    // Responses from the server (code and message)
    serverResponseCode = connection.getResponseCode();
    serverResponseMessage = connection.getResponseMessage();

    catch (Exception ex)
    //Exception handling

    I can't use that code in Skatchware. Why? will you Please make it work?

    1. What is the use of this code?
      I could Compile without errors, but to use it, it should be used as a class, which needs to be called later for displaying results.

  4. Sir,if want to keep adding the text in the same file.write on same i can??

  5. Sense sketchware removed the "add source block" I've found a workaround easily using a shared preferences file, a webview hidden and writing the java into a html saved directly to the shared preference file and calling it when the app runs using 'script' open and close tags in a dummy html text file saved within the shared preferences file. When your app runs it opens the file wide open for java while hidden from view allowing direct insertion. Hahaha.They pissed me off and can't stop us. Lol


Post a Comment

Popular posts from this blog

Create Music Player app in Sketchware

A Flash Light App in Sketchware

Admob rewarded video Ads in Sketchware

Simple car racing android game in Sketchware

Firebase auth in Sketchware for Login Activity