Book Image

Testing and securing android studio applications

Book Image

Testing and securing android studio applications

Overview of this book

Table of Contents (18 chapters)
Testing and Securing Android Studio Applications
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

File Explorer


The File Explorer tab exposes the whole filesystem of the device. We can examine the size, date, or permissions for each element. Navigate to /data/app/yourpackage to search for your application .apk package file. To check the path in which your files are saved when they are created on internal storage, you can use the getFilesDir() method in your activity. The files related to your application are usually located at /data/data/yourpackage. Let's perform an example.

Create a new project and in the main layout add a button named, for example, Create New File. Create a new method to be executed when the button is clicked and add the following code:

public void createNewFile(View v){
  String string = "Hello world!";
  FileOutputStream outputStream;

  try {
    outputStream = openFileOutput("MyFile", MODE_PRIVATE);
    outputStream.write(string.getBytes());
    outputStream.close();
  } catch (Exception e) { e.printStackTrace(); }
}

Using the previous code, you are creating a new...