Android: Storing Image into project directory (files)?

I want to store my Bitmap image into project directory. How can I have access to my project folder or what is the address of my project folder?


You have to put the images in the res/drawable folder. Then, you can access them by using: R.drawable.name_of_image (for name_of_image.png or name_of_image.jpg).

If you want to access them by their original name, you better save them in the assets folder. Then, you can access them by using the AssetManager:

AssetManager am = getResources().getAssets();
try {
    InputStream is ="image.png");
    // use the input stream as you want
} catch (IOException e) {

If you want to save a programatically created image, you can do:

try {
       FileOutputStream out = new FileOutputStream(context.getFilesDir().getAbsolutePath()+"/imagename.png");
       bmp.compress(Bitmap.CompressFormat.PNG, 100, out);
} catch (Exception e) {

You can't save it to your project directory. I recommend you to read the documentation about how android packages work, because it seems you don't understand.

Need Your Help

Multiple models sent to a single view instance model

My terminology is probably way off here but basically I'm trying to pass multiple data models to a view. To help put the question in context, take this example:

.Net exception catching in subclasses

.net exception attributes

In .net, how do I make the guy that writes a subclass aware that they need to code for a specific exception type that a base class may throw? Ideally I'm looking to force a developer to either try....

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.