get Data Directory - Android java.io

Android examples for java.io:Directory

Description

get Data Directory

Demo Code

import java.io.IOException;

import android.content.Context;
import android.content.pm.PackageManager;

public class Main {

  public static String getDataDirectory(Context context) throws IOException {
    try {/* ww  w.  ja va2s .c o m*/
      return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).applicationInfo.dataDir;
    } catch (PackageManager.NameNotFoundException nnfe) {
      throw new IOException("Cannot access to data directory", nnfe);
    }
  }

}

Related Tutorials