How to find the path of a folder on android?

2

I am using the AWS SDW (Amazon Web Services) to send data to the AWS IOT with my application. In this application I first have to connect with AWS IOT. The method to connect me needs a keyStore. I have this keyStore and I have it saved in a folder on my mobile.

The problem is that to access this file I have to do it by reference by a string and the name of the keyStore. ( keyStorePath is a string just like the name).

if (AWSIotKeystoreHelper.isKeystorePresent(keystorePath, KEYSTORE_NAME)) {

With this method I simply check that the keyStore is there, but it always returns false since I do not correctly reference the path since I do not know where it starts (root) and I do not know how to reference the folder.

A solution that I thought would be to load the keyStore in the application in a folder, but I do not know how to get the path since it starts from "c / users / ..." which is my computer.

    
asked by Fran Moreno 17.04.2017 в 16:24
source

1 answer

1
  

I have this keyStore and I have it stored in a folder on my mobile phone.

The correct way to get the keystore route is to use:

 String keystorePath = getFilesDir().getPath();

to get the route that is usually:

 ../data/data/<com.dominio.myapplication>/files

Regarding the name of the keystore, simply define it in the static variable:

private static final String KEYSTORE_NAME = "awskeystore";

Review an example of AWS: link

    
answered by 17.04.2017 в 17:20