android - Image into SQLite and not to gallery -


i have requirement store image in android app , shouldn't appear in gallery.so, decided have sqlite database in app 'assets' folder , store imagepath database. problem is, if not sdcard, how imagepath? or there way hide images captured app appearing in gallery. below code using store images in external directory.

photo = new file(environment.getexternalstoragepublicdirectory(environment .directory_pictures), imagename);  //imagename=current timestamp 

i'm using method save images internal storage (and save returned path sqlite)

    private string savetointernalstorage(bitmap bitmapimage, string filename){     contextwrapper cw = new contextwrapper(getapplicationcontext());     // path /data/data/yourapp/app_data/imagedir     file directory = cw.getdir("imagedir", context.mode_private);     log.d("dir", directory.tostring());     // create imagedir     file mypath=new file(directory,filename);     log.d("path", mypath.tostring());      fileoutputstream fos = null;     try {          fos = new fileoutputstream(mypath);          // use compress method on bitmap object write image outputstream         bitmapimage.compress(bitmap.compressformat.png, 100, fos);         fos.close();     } catch (exception e) {         e.printstacktrace();     }     log.d("ingesteld path", directory.getabsolutepath());     return directory.getabsolutepath(); } 

load images using:

private void loadimagefromstorage(string path, string name) {     try {         file f=new file(path, name);         bitmap b = bitmapfactory.decodestream(new fileinputstream(f));          // bitmap     }     catch (filenotfoundexception e)     {         e.printstacktrace();     }  } 

hope of use.


Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -