Hi, Thanks a lot for the problem, but I'm still unfortunately at square one.
#### Here is what I need: Read an SMS into a string variable, then do some string operations. For example, how can I find the first character of an SMS? Thanks in advance for helping me out. ########################### On 1/6/09, Ninad <mnina...@gmail.com> wrote: > > > Hi.. > > All you need is simple SQL.. > > Modify the Cursor as: > > Cursor c= getContentResolver().query(uri, null, "body like > '%hello%'", null,null); > > Since the query takes the following argument: > > public final Cursor query(Uri uri, String[] projection, String > selection, String[] selectionArgs, String sortOrder) > . > Arguments: > > uri: The URI, using the content:// scheme, for the content to > retrieve. > projection: A list of which columns to return. Passing null will > return all columns, which is discouraged to prevent reading data from > storage that isn't going to be used. > selection: A filter declaring which rows to return, formatted as an > SQL WHERE clause (excluding the WHERE itself). Passing null will > return all rows for the given URI. > selectionArgs: You may include ?s in selection, which will be > replaced by the values from selectionArgs, in the order that they > appear in the selection. The values will be bound as Strings. > sortOrder: How to order the rows, formatted as an SQL ORDER BY clause > (excluding the ORDER BY itself). Passing null will use the default > sort order, which may be unordered. > > > I hope this solves your simple query for 'experts'! > > On Jan 6, 9:31 am, ipeg.stud...@gmail.com wrote: > > Hi! am Suman. I have a code by which i can access all the sms from > > inbox. The code is written below. > > > > import android.app.ListActivity; > > import android.content.ContentUris; > > import android.content.Intent; > > import android.database.Cursor; > > import android.net.Uri; > > import android.os.Bundle; > > import android.provider.Contacts.People; > > import android.provider.Telephony.Carriers; > > > > import android.telephony.gsm.SmsMessage; > > import android.view.View; > > import android.widget.ListAdapter; > > import android.widget.ListView; > > import android.widget.SimpleCursorAdapter; > > > > public class niceandroid8 extends ListActivity { > > > > private ListAdapter mAdapter; > > > > /** Called when the activity is first created. */ > > @Override > > public void onCreate(Bundle icicle) { > > super.onCreate(icicle); > > Uri uri = Uri.parse("content://sms/inbox"); > > Cursor c = getContentResolver().query(uri, null, null, > > null,null); > > // Cursor c = getContentResolver().query(Carriers.CONTENT_URI, > > null, null, null, null); > > startManagingCursor(c); > > > > String[] columns = new String[]{"body"}; // Comment > > int[] names = new int[]{R.id.row_entry}; > > > > mAdapter = new SimpleCursorAdapter(this, R.layout.con1, c, > > columns, names); > > > > this.setListAdapter(mAdapter); > > } > > > > } > > > > xml coding is.......... > > > > <?xml version="1.0" encoding="utf-8"?> > > > > <LinearLayout xmlns:android="http://schemas.android.com/apk/res/ > > android" > > android:orientation="horizontal" > > android:layout_width="fill_parent" > > android:layout_height="wrap_content" > > > > > <TextView > > android:layout_width="wrap_content" > > android:layout_height="wrap_content" > > android:text="Sms: " > > /> > > <TextView > > android:id="@+id/row_entry" > > android:layout_width="wrap_content" > > android:layout_height="wrap_content" > > /> > > </LinearLayout> > > > > > /////////////////////////////////////////////////////////////////////////// > ///////////////////////////////////////////////////////////////// > > Now my problem is i want to access those sms which have a specific > > string . As a example .... > > if any sms contains "Hello". So i want to search the string. i have > > tried a lot. But i cant do this beacause i cant convert the > > Listadapter to String. Please help me and give me the correct code. > > > /////////////////////////////////////////////////////////////////////////// > ///////////////////////////////////////////////////////////////// > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---