I want to create a form where the person can save his data with upload image option. And save all data in SQLiteDatabase.
Thanks in Advance
I want to create a form where the person can save his data with upload image option. And save all data in SQLiteDatabase.
Thanks in Advance
Check this answer storing image into SQLite in android but actually storing images in database not a good practice. Better save image on SD Card and insert into DB only path to this image.
Official tutorial how to save data in SQLite http://developer.android.com/training/basics/data-storage/databases.html
You can insert image in byte array format in sqlite. To store byte array you need to define a column with blob type format.
and then you can simply do like that :-
public void storeImage(Bitmap img){
byte[] data = getBitmapAsByteArray(img);
SQLiteDatabase db=database.getWritableDatabase();
db.execSQL("INSERT INTO IMAGETABLE VALUES(data);");
}
public static byte[] getBitmapAsByteArray(Bitmap bitmap) {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
bitmap.compress(CompressFormat.PNG, 0, outputStream);
return outputStream.toByteArray();
}