0

i want to add a image to my simple database don't know what to add to the code below. the image is a byte and i am wondering what to add to the updatecontact column.

 public void run(View view)
{   
  Bundle extras = getIntent().getExtras();
  if(extras !=null)
  {
     int Value = extras.getInt("id");
     if(Value>0){
        if(mydb.updateContact(id_To_Update,name.getText().toString(), phone.getText().toString(), email.getText().toString(), street.getText().toString(), place.getText().toString())){
           Toast.makeText(getApplicationContext(), "Updated", Toast.LENGTH_SHORT).show();   
           Intent intent = new Intent(getApplicationContext(),com.example.addressbook.MainActivity.class);
           startActivity(intent);
         }      
        else{
           Toast.makeText(getApplicationContext(), "not Updated", Toast.LENGTH_SHORT).show();   
        }
     }
     else{
        if(mydb.insertContact(name.getText().toString(), phone.getText().toString(), email.getText().toString(), street.getText().toString(), place.getText().toString())){
           Toast.makeText(getApplicationContext(), "done", Toast.LENGTH_SHORT).show();  
        }       
        else{
           Toast.makeText(getApplicationContext(), "not done", Toast.LENGTH_SHORT).show();  
        }
        Intent intent = new Intent(getApplicationContext(),com.example.addressbook.MainActivity.class);
        startActivity(intent);
        }
  }
}
  • 1
    2 way to implement this. First convert image to hex and save to data base on retrieve convert back from hex to image not good way at all will kill performance. second way to save it on external storage as sd in app folder and in data base save only a name of image as image1.jpg and then load from extornal storage by file name. – Constantin Cerberus Jul 14 '14 at 13:56
  • but is thier any way i can add it without converting the byte – user3570270 Jul 14 '14 at 14:22
  • NO see here documentation about SQLite http://www.sqlite.org/datatype3.html there you can see all data types available for you to use one of theme is BLOB to save binry data. also you can reade here about storing images is SQLite here http://stackoverflow.com/questions/9308978/saving-image-into-sqlite – Constantin Cerberus Jul 14 '14 at 14:34

0 Answers0