Ideas:
Http://www.eoeandroid.com/thread-81618-1-1.html
If the image is under drawable, you can save the image ID to the database,
To save the path, you can put the image under the assets folder.
Absolute path:
Http://blog.csdn.net/svrsimon/article/details/7079320
Method 1:
String Path = file: // android_asset/file name;
Method 2:
Inputstream abpath = getclass (). getresourceasstream ("/assets/file name"); // to convert to string type string Path = new string (inputstreamtobyte (abpath); Private byte [] inputstreamtobyte (inputstream is) throws ioexception {bytearrayoutputstream bytestream = new bytearrayoutputstream (); int ch; while (CH = is. read ())! =-1) {bytestream. Write (CH);} byte imgdata [] = bytestream. tobytearray (); bytestream. Close (); Return imgdata ;}
Differences between the Assets Directory and the Res/raw and Res/drawable Directories
Http://superonion.iteye.com/blog/1424244
1. The resource files in the Assets Directory do not automatically generate IDS in R. java. Therefore, the file path must be specified to read files in the Assets Directory. You can access these files through the assetmanager class. To read background.png under the assetsdirectory:
Bitmap bgimg = getimagefromassetfile ("background.png");/*** read image from assets */private bitmap getimagefromassetsfile (string filename) {bitmap image = NULL; assetmanager AM = getresources (). getassets (); try {inputstream is = aM. open (filename); image = bitmapfactory. decodestream (is); is. close ();} catch (ioexception e) {e. printstacktrace ();} return image ;}
1. Place the image in sdcard,
Bitmap imagebitmap = bitmapfactory. decodefile (PATH) (path is the path of the image, and the directory is/sdcard)
2. The image is in the res folder of the project.
// Obtain the application object applicationinfo appinfo = getapplicationinfo (); // obtain the image ID (name is the image name, "drawable" is the directory where the image is stored, appinfo. packagename is the package of the application.) int resid = getresources (). getidentifier (name, "drawable", appinfo. packagename); // The Code is as follows: public bitmap getres (string name) {applicationinfo appinfo = getapplicationinfo (); int resid = getresources (). getidentifier (name, "drawable", appinfo. packagename); Return bitmapfactory. decoderesource (getresources (), resid );}
3. Place the image in the src directory.
String Path = "com/xiangmu/test.png"; // The path where the image is stored. inputstream is = getclassloader (). getresourceasstream (PATH); // obtain the image stream
4. There is an Assets Directory in Android. Read-Only files can be stored here.
// The method for obtaining resources is inputstream is = getresources (). getassets (). Open (name );