Save Bitmap for a future use in the application

Hello again.

Now we learned how to create an image, show thumbnail in the app and zoom it out.  Next step I have to save this image (bitmap) somewhere so that app can use it. Normally in enterprise application this would be saved in Oracle database under another table with userId and itemId. I am tempted to create a new table in SQLite and link it with other tables. Before going for it let’s explore if better alternative exists for android. I am hoping for ability to save image  using content provider and stick URI into my table for allergen descriptors.

What people say..

Uri.fromFile(new File(Environment.getExternalStorageDirectory(), “your_file_name”)))

Save ringtone to sdcard: This is asking for a specific folder name on sd card. How do I know if card exists.. and what folders already are there.  They create a folder if it doesn’t exists. Maybe.

This seems more hopeful  But people say that saving images in SQLite is not a good practice.

This has code for downloading stream and saving into file. Bit I don’t have stream. How would I make a stream out of bitmap?

Going with SQLite database solution though it’s not a good practice I only have few images.

Next issue: database model planning. I already have couple tables. And I had 4 tables in a previous app. Will try to organize it more efficient but prevent complex queries.

Spent 4-6 hours refactoring so I track items by id and can translate individual items not lists. This was my smart caching task. Almost done need more verifications and bugfixes.

I have now images table that are id’ed by group id. Can be saved/restored as byte[]. Still debugging, zoom is not working after a round trip to a database.

Have to finish this before noon.  Next will be drop down for categories, I never did dropdown menus.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s