+7 votes
1.4k views
in Android by
Hello Ramon, first thank you in advance for these answers. Well once I start I miss a mess with this really: I'll try yourself explain as best I can.
I have created a database sqlite data, which have saved the direction or path to a photograph (in addition to other fields) or what I do is a query to the database, the response I get the path and turn this path stick it Extras as an intent to launch another activity until here everything well.
I want to clarify that the photograph in question is in the internal SD device, in a file created by me for this app.
This is the path = file: ///storage/emulated/0/Pictures/Fotos_Lugar/Lugar_20140930_142116.JPG
 
Now when I try to convert the file in this path into a bitmap is when tells me nothing.
 
  1. BitmapFactory.Options options = new BitmapFactory.Options();
  2. options.inPreferredConfig = Config.ARGB_8888;
  3. Bitmap imagen = BitmapFactory.decodeFile(path_de_la_ruta_donde_esta_la_foto, options);
 
I'm thinking that maybe this activity is not part of the same answer. If so how could he replied happen? .That Method ?, could use anything you can think of me would come good. I said thank you very much. A greeting.

1 Answer

+8 votes
by (201k points)
If you're working on a class that inherits from Activity Context you are inheriting from, so you do not need to pass the context (if you want to ensure call getApplicationContext () method to get the Context of the application).
Be sure to be getting the path in the decodeFile method and that the file exists. You should also get the external route by some method of Android, never hand (imagine that a mobile is not called a part of the path "storage" but "drive" as the absolute path does not work). I'm writing a simple and practical example to do what you need:
 
  1. String FICHERO = "Nombre_del_fichero.png";
  2. File ruta = getExternalFilesDir(null);
  3. File fichero = new File(ruta, FICHERO);
  4. if (fichero.mkdirs()) {
  5. Bitmap myBitmap = BitmapFactory.decodeFile(fichero.getAbsolutePath());
  6. }

 

Ask a Question
Welcome to WikiTechSolutions where you can ask questions and receive answers from other members of the community.

You can ask a question without registration.

Categories

...