with Content Providers"
I try to use the same thing like the following exemple:
http://developer.android.com/intl/fr/gu ... ontent-p...
with a Bitmap:
Using java Syntax Highlighting
- import android.provider.Contacts.People;
- import android.content.ContentResolver;
- import android.content.ContentValues;
- ContentValues values = new ContentValues();
- // Add Abraham Lincoln to contacts and make him a favorite.
- values.put(People.NAME, "Abraham Lincoln");
- // 1 = the new contact is added to favorites
- // 0 = the new contact is not added to favorites
- values.put(People.STARRED, 1);
- Uri uri = getContentResolver().insert(People.CONTENT_URI, values);
Parsed in 0.032 seconds, using GeSHi 1.0.8.4
Using java Syntax Highlighting
- Uri phoneUri = null;
- Uri emailUri = null;
- // Add a phone number for Abraham Lincoln. Begin with the URI for
- // the new record just returned by insert(); it ends with the _ID
- // of the new record, so we don't have to add the ID ourselves.
- // Then append the designation for the phone table to this URI,
- // and use the resulting URI to insert the phone number.
- phoneUri = Uri.withAppendedPath(uri, People.Phones.CONTENT_DIRECTORY);
- values.clear();
- values.put(People.Phones.TYPE, People.Phones.TYPE_MOBILE);
- values.put(People.Phones.NUMBER, "1233214567");
- getContentResolver().insert(phoneUri, values);
- // Now add an email address in the same way.
- emailUri = Uri.withAppendedPath(uri, People.ContactMethods.CONTENT_DIRECTORY);
- values.clear();
- // ContactMethods.KIND is used to distinguish different kinds of
- // contact methods, such as email, IM, etc.
- values.put(People.ContactMethods.KIND, Contacts.KIND_EMAIL);
- values.put(People.ContactMethods.DATA, "test@example.com");
- values.put(People.ContactMethods.TYPE, People.ContactMethods.TYPE_HOME);
- getContentResolver().insert(emailUri, values);
Parsed in 0.033 seconds, using GeSHi 1.0.8.4
So I think is too similar but I'm really lose !!
Firstly I don't find how to create my File with my byte[].
I try to make that:
Using java Syntax Highlighting
- byte[] decoded = Base64.decode( tabMsg[0].getMsgBase64() );
- ContentValues values = new ContentValues();
- values.put(Media.DISPLAY_NAME, "Voicemail1");
- values.put(Media.MIME_TYPE, "Audio/wav");
- Uri uri = getContentResolver().insert(Media.EXTERNAL_CONTENT_URI,
- values);
- File m_wav = new File(uri.getEncodedPath(), "voicemail1.wav");
- try
- {
- OutputStream outStream = getContentResolver().openOutputStream
- (uri);
- outStream.write(decoded);
- outStream.close();
- }
- catch (Exception e)
- {
- Log.e(TAG, "Exception while writing audio", e);
- }
Parsed in 0.036 seconds, using GeSHi 1.0.8.4
Could you light me, please ??
What are you thinking about my little code and how can I
continuous ???
It's very hard to use the better arguments or parametres with:
values.put(...) and with : getContentResolver().insert(..)
Maybe I have to create my own Content Providers but I think is too
compicated !
Dayn


