I am able to read mms image from device using query "content://mms/part" and sending those mmsimages to server , but my requirement is in my application i will read all the mms images from device and backup to server from the second time when app is opened i need to backup only latest mms to the server , for this requirment i need to read the mms from the device after particular date given by me . is it possible?
Cursor curPart = getContentResolver (). query (Uri.parse ("content://mms/part"), null, null, null, null);
while(curPart.moveToNext())
{
coloumns = curPart.getColumnNames();
for(int i=0;i<coloumns.length;i++)
{
Log.e("coloumns",coloumns[i]);
}
if(values == null)
values = new String[coloumns.length];
for(int i=0; i< curPart.getColumnCount(); i++)
{
values[i] = curPart.getString(i);
}
if(values[3].equals("image/jpeg"))
{
mms_image.add(GetMmsAttachment(values[0],values[12],values[4]));
}
}
private String GetMmsAttachment(String _id, String _data,String fileName )
{
Uri partURI = Uri.parse("content://mms/part/" + _id );
ByteArrayOutputStream baos = new ByteArrayOutputStream();
InputStream is = null;
try {
is = getContentResolver().openInputStream(partURI);
convertBitmapToFile(bitmap);
byte[] buffer = new byte[256];
int len = is.read(buffer);
while (len >= 0) {
baos.write(buffer, 0, len);
len = is.read(buffer);
}
}
catch (IOException e)
{
e.printStackTrace();
//throw new MmsException(e);
}
finally
{
if (is != null)
{
try
{
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
//writeToFile(bais,"data/",fileName);
is.close();
bais.close();
}
catch (IOException e)
{`enter code here`
e.printStackTrace();
}
}
}
return strMyImagePath;
}