I want to have a single folder where I will put all the resources I’m going to need and I want it on the internal storage. Since I want this directory to be created only once, I found out that I should create it in the main activity of the application:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
File directory = context.getDir("mydir", Context.MODE_PRIVATE);
Log.d("directory", directory.getAbsolutePath().toString());
}
It seems ok as this is what I was able to find on the internet, however I am receiving loads of erros, I can get to the log for the directory path and the application doesn’t start. Any idea why?
Also, if I work with internal storage every time when I run my application from Eclipse to my phone, does it automatically deletes the previous one together with its resources or I’ve to do that manually?
use
getCacheDir(). It returns the absolute path to the application specific cache directory on the filesystem. Then you can create your directory