I have a database and a method, which can get all my info from my database to a TextView. It shows only the Title of each row, there are more columns, which I want to show on new Intent when I click on a Title. My question is, how can I make each title clickable and if clicked it opens up a new intent with the relevant information(need to pass the id)? Many thanks. :)
My History Activity -
public class HistoryActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.history_layout);
final LinearLayout linearLayoutBackground = (LinearLayout) findViewById(R.id.MainLinearLayout);
TextView tv = (TextView) findViewById(R.id.tvHistory);
DataBaseHelper DataBaseHelper = new DataBaseHelper(this);
Intent mIntent = getIntent();
int intValue = mIntent.getIntExtra("intVariableName", 0);
int backgroundImages[] = {R.drawable.background1,
R.drawable.background2};
final Drawable backgroundImage = getResources().getDrawable(
backgroundImages[intValue]);
linearLayoutBackground.setBackgroundDrawable(backgroundImage);
DataBaseHelper.open();
String HistoryData = DataBaseHelper.getListData();
DataBaseHelper.closee();
tv.setText(HistoryData);
}
}
getListData method -
public String getListData() {
open();
Cursor c = myDataBase.query(TABLE_NAME1, columns, WHATTODONOW_COLUMN_ID, null, null, null, null);
String result = "";
int iTitle = c.getColumnIndex(WHATTODONOW_COLUMN_TITLE);
for (c.moveToFirst(); !c.isAfterLast(); c.moveToNext()) {
result = result + c.getString(iTitle) + "\n";
}
return result;
}
HistoryLayout -
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/MainLinearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TableLayout
android:id="#+id/tableLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:paddingTop="10dp">>
<TableRow>
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center"
android:text="All the things you have already done!"
android:textSize="20dp"
android:textStyle="bold">
</TextView>
</TableRow>
</TableLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingBottom="15dp"
android:paddingLeft="15dp"
android:paddingRight="15dp">
<TextView
android:id="#+id/tvHistory"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:text="get info from db"
android:paddingBottom="10dp"
android:textSize="25dp">
</TextView>
</ScrollView>
</LinearLayout>
There are two ways to go from my experience. First instead of using a ListView you look at ExpandableListView, which might accomplish what you want in one activity instead of having to start another intent.
Second, if you want to stick with the 2 intent design you have to pass some data from the current intent to the new one, you could do something like:
Intent i = new Intent(yourcurrentactivity.this, yournewactivity.class);
// following line is an example of passing data to the new intent.
i.putExtra(getString(R.string.str_selecteddialog), "1");
startActivity(i);
this.finish();
In the new intent that you have started in the onCreate you need to retrieve the data from the bundle:
Bundle extras = getIntent().getExtras();
if (extras != null) {
// Log.i(TAG, " 022:... we got some extras");
str_selecteddialog = getIntent().getStringExtra(getString(R.string.str_selecteddialog));
There are different types of put and get 'Extras' dependent on variable types. Now you have to decide: Do I get all the data from the cursor and pass it to this new intent or Do I just pass the row id column, typically '_id' and query it in this activity.
Hope this helps.
Related
I have 2 Activities, first to send data and the other pastes this data in a RecyclerView.
My problem is when I press on the button to take the data from the EditTexts and move them to the RecyclerView, it only updates the RecyclerView. I mean it shows only the first item which was put before, but when I try to add more data to the RecyclerView it overwrites them in the first item.
Here are my activities and layouts:
The Sender Activity
btn_save.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
if (etTitle.length() != 0 || etDes.length() != 0){
String titled = etTitle.getText().toString();
String desed = etDes.getText().toString();
Bundle bund = new Bundle();
bund.putString("title", titled);
bund.putString("des", desed);
Intent inte = new Intent(getApplicationContext(), MainActivity.class);
inte.putExtras(bund);
startActivity(inte);
}else {
Toast.makeText(DataInput.this, "Please Add Data !", Toast.LENGTH_SHORT).show();
}
}
});
The Receiver Activity:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
FloatingActionButton fab = findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Intent intent = new Intent(getApplicationContext(), DataInput.class);
startActivity(intent);
}
});
recyclerView = findViewById(R.id.rv);
dAdapter = new DataAdapter(dataList);
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getApplicationContext());
recyclerView.setLayoutManager(layoutManager);
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.setAdapter(dAdapter);
bundle = getIntent().getExtras();
if (bundle != null) {
sendData();
}
}
private void sendData() {
String addedTitle = bundle.getString("title");
String addedDes = bundle.getString("des");
Data data = new Data(addedTitle, addedDes);
dataList.add(data);
dAdapter.notifyDataSetChanged();
}
My XML Files:
activity_main.xml:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#drawable/pen2"
tools:context=".MainActivity">
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="#dimen/fab_margin"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
app:backgroundTint="#a40038"
app:srcCompat="#mipmap/add" />
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/rv">
</android.support.v7.widget.RecyclerView>
list_item.xml:
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="#606c6c6c"
android:layout_margin="10dp"
app:cardElevation="8dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/tv_title"
android:textSize="25sp"
android:textStyle="bold"
android:textColor="#fff"
android:fontFamily="#font/mohave"
android:layout_marginTop="10dp"
android:layout_marginLeft="15dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/tv_des"
android:textSize="20sp"
android:textColor="#fff"
android:fontFamily="#font/mohave"
android:layout_marginTop="10dp"
android:layout_marginLeft="15dp"
android:layout_marginBottom="10dp"/>
</LinearLayout>
When you come back to your Sender activity and then again go to the receiver activity, you are sending data in a bundle (A fresh bundle). This bundle doesn't have any older data and when the receiver activity receives data from this bundle, it creates a new data (the previous data is being erased with a new data (sent from the sender) every time).
You need to store your previous data when you come back to your Sender activity.
One way to achieve this is to store the receiver's data locally in a database (A bad practice).
What you can do is in your Sender activity, use
startActivityForResult()
instead of
startActivity()
and override the onBackPressed() in your receiver activity.
and onBackPressed(), send the 'data' variable back to your sender activity and append that data with the new data while sending it again to the receiver activity.
Or every time you send your bundle, instead of sending a string, send an array of strings (Having previous data). (Simplest solution)
Please let me know if you need any help with the code.
Change the position of this code
bundle = getIntent().getExtras();
if (bundle != null) {
sendData();
}
to above , before initializing and setting the adapter.
And save your list , before leaving the activity to save the past values.
Hope this helps.
i am new to android, i am developing an app similar to Notepad. My notepad files are saved in the form of ListView, where the listview contains a TextView and a button. Button is for delete option to remove data from the database, which it is working successfully, but the problem is with the TextView, my intention is when a user clicks any file in the listview (i.e.,TextView), i want to open that file without losing previous data written in notepad, so that he can update the data. Any help is appreciated.
This is my java file,
public void deleteTask(View view) {
View parent = (View) view.getParent();
TextView taskTextView = (TextView) parent.findViewById(R.id.task_title);
String task = String.valueOf(taskTextView.getText());
SQLiteDatabase db = mHelper.getWritableDatabase();
db.delete(TaskContract.TaskEntry.TABLE,
TaskContract.TaskEntry.COL_TASK_TITLE + " = ?",
new String[]{task});
db.close();
updateUI();
}
and
public void click(View view) {
View parent = (View) view.getParent();
TextView taskTextView = (TextView) parent.findViewById(R.id.task_title);
String task = String.valueOf(taskTextView.getText());
SQLiteDatabase db = mHelper.getReadableDatabase();
db.openDatabase( getDatabasePath(task), SQLiteDatabase.CursorFactory null,int flags);
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
startActivity(intent);
}
This is my xml file
<TextView
android:id="#+id/task_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:text="#string/app_name"
android:textSize="20sp"
android:onClick="click"/>
<Button
android:id="#+id/task_delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:text="Delete"
android:onClick="deleteTask"/>
and another xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.example.shiva.secretbook.TodoList">
<ListView
android:id="#+id/list_todo"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
I think this code is enough to solve my question. Thanks in advance
I'm trying to create a 'favourites' view dynamically in android by recording whether the user has favoured a specific sound bite in my app and then inserting the sub view into a parent view with the appropriate info about a particular soundbite. Essentially, creating a custom playlist of soundbites.
I'm having problems with the layoutInflator though. If I add more than one sub view into my parent view, only the last sub view added will have the appropriate parameters entered, whereas the rest have the default values from the sub view xml layout.
Here is my java code displaying the general idea behind adding subviews:
LayoutInflater l = getLayoutInflater();
LinearLayout ll = (LinearLayout)findViewById(R.id.favlist);
if(getIntent().getExtras()!=null)
{
Bundle extras = getIntent().getExtras();
Intent test = getIntent();
if(test.hasExtra("favThunder")){
String favValues = extras.getString("favThunder");
View v = l.inflate(R.layout.sublayout, null);
ll.addView(v);
ImageView favImage = (ImageView)findViewById(R.id.favimage);
favImage.setImageResource(R.drawable.thundercats);
TextView tv = (TextView) findViewById(R.id.favtitle);
tv.setText(R.string.thundercats);
TextView tvClicks = (TextView) findViewById(R.id.timesplayed);
tvClicks.setText("Times played: " + favValues);
favImage.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
if (mp.isPlaying()) {
mp.stop();
}
mp = MediaPlayer.create(getApplicationContext(), R.raw.thunder);
mp.start();
}
});
}
if(test.hasExtra("favSkeletor")){
String favValues = extras.getString("favSkeletor");
View v = l.inflate(R.layout.sublayout, null);
ll.addView(v);
ImageView favImage = (ImageView)findViewById(R.id.favimage);
favImage.setImageResource(R.drawable.skeletor);
TextView tv = (TextView) findViewById(R.id.favtitle);
tv.setText(R.string.skeletor);
TextView tvClicks = (TextView) findViewById(R.id.timesplayed);
tvClicks.setText("Times played: "+favValues);
favImage.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
if (mp.isPlaying()) {
mp.stop();
}
mp = MediaPlayer.create(getApplicationContext(), R.raw.skeletor);
mp.start();
}
});
}
And here is my sub view and parent view xml respectively
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageButton
android:id="#+id/favimage"
android:layout_width="0dp"
android:layout_weight="0.5"
android:layout_height="200dp"
android:src="#drawable/thundercats"
android:scaleType="fitCenter"/>
<LinearLayout
android:layout_weight="0.5"
android:layout_width="0dp"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="#+id/favtitle"
android:layout_weight="0.4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="A TEST TITLE"/>
<TextView
android:layout_weight="0.3"
android:id="#+id/timesplayed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Times played: Heck!"/>
</LinearLayout>
</LinearLayout>
Parent xml
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
tools:context="com.example.markohare.ohareb00716779_cw1.MainActivity"
>
<LinearLayout
android:id="#+id/favlist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dp">
</LinearLayout>
</ScrollView>
What am I doing wrong? Is my subview too complex or is there something wrong in my java code?
Thanks
I have EditViews to prompt the user for a min and max. The data entered is passed into an Activity function and a random number is generated. That random number is passed onto another Activity to be displayed. When I enter a min number and a max number and then click the button that says generate, I get directed to a blank screen. However, I'm expecting randValue to be displayed.
MainActivity.java
public class MainActivity extends AppCompatActivity {
public final static String RAND_NUM = "com.example.random.MESSAGE";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void generateNum(View view) {
Intent intent = new Intent(this, DisplayNumActivity.class);
EditText minInput = (EditText) findViewById(R.id.min_num);
EditText maxInput = (EditText) findViewById(R.id.max_num);
int minNum = Integer.parseInt(minInput.getText().toString());
int maxNum = Integer.parseInt(maxInput.getText().toString());
Random rand = new Random();
int randNum = rand.nextInt(maxNum - minNum) + minNum;
intent.putExtra(RAND_NUM, randNum);
startActivity(intent);
}
}
DisplayNumActivity.java
public class DisplayNumActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_display_num);
Intent intent = getIntent();
String randValue = intent.getStringExtra(MainActivity.RAND_NUM);
TextView textView = new TextView(this);
textView.setTextSize(30);
textView.setText(randValue);
ViewGroup layout = (ViewGroup) findViewById(R.id.activity_display_num);
layout.addView(textView);
}
}
activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
tools:context="com.example.random.MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Min number"
android:id="#+id/textView"
android:layout_marginTop="40dp"
android:layout_alignParentTop="true"
android:layout_alignLeft="#+id/textView2"
android:layout_alignStart="#+id/textView2" />
<EditText
android:id="#+id/min_num"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="min"
android:inputType="number"
android:layout_marginTop="32dp"
android:layout_below="#+id/textView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Max number"
android:id="#+id/textView2"
android:layout_marginTop="43dp"
android:layout_below="#+id/min_num"
android:layout_centerHorizontal="true" />
<EditText
android:id="#+id/max_num"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="max"
android:inputType="number"
android:minWidth="500dp"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/button_text"
android:onClick="generateNum"
android:id="#+id/button"
android:layout_below="#+id/max_num"
android:layout_centerHorizontal="true"
android:layout_marginTop="43dp" />
OK, two things:
1) In DisplayNumActivity, change
String randValue = intent.getStringExtra(MainActivity.RAND_NUM);
to this:
int randValue = intent.getIntExtra(MainActivity.RAND_NUM, 0);
Here we are reading in an int value from the intent instead of a String. In your main activity you saved an int here, not a String, the String here is just the "key" in the key-value pair. The zero is just a default in case it can't find your int.
2) To display the number you have to first change that int back to a String in order to set it in a TextView and then we display it to your relative layout like this:
String stringRandValue = Integer.toString(randValue);
View relativeLayout = findViewById(R.id.activity_display_num);;
TextView textView = new TextView(this);
textView.setTextSize(30);
textView.setText(stringRandValue);
((RelativeLayout)relativeLayout).addView(textView);
That should work.
Replace this
String randValue = intent.getStringExtra(MainActivity.RAND_NUM);
With this
String randValue = intent.getIntExtra(MainActivity.RAND_NUM,
default_int_value);
I think you have to specify exactly which layout you want to add your textview to.
Like: RelativeLayout relativelayout = (RelativeLayout)findViewById(R.id.relativelayoutID);
Casting to viewgroup seems bit heavy to me. Please try suggested way and let me know if it changes anything for you.
Edit: There is one more thing which I feel might be the culprit in this case and that is missing layout params for your text View.
Example:
//create params like this
LayoutParams layoutparams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT );
//set layout params like this
textView.setLayoutParams(layoutparams);
Note - replace the parent layout type according to your xml where this textView is been added.
Why I cannot retrieve data from SQLite? Have I missed out something? I have read many documentation and tried to work it out, but still fail.
WorkDetailsTable.java
Button btn1=(Button)findViewById(R.id.button2);
btn1.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
AlertDialog.Builder builder=new AlertDialog.Builder(WorkDetailsTable.this);
builder.setTitle("Data Saved");
builder.setMessage("Are you sure you want to save?");
builder.setIcon(android.R.drawable.ic_dialog_alert);
builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int ii) {
long ab = ts.insertTimeSheet(name, weather, date, status);
Toast.makeText(context, "Data Saved", Toast.LENGTH_SHORT).show();
Intent intent=new Intent(WorkDetailsTable.this,DisplayData.class);
intent.putExtra("name",name); //name will be used in another class
startActivity(intent);
DisplayDate.java
public class DisplayData extends AppCompatActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.displaydata);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
final String name1 = getIntent().getExtras().getString("name");
Toast.makeText(getApplicationContext(),name1, Toast.LENGTH_SHORT).show();
if(name1.equals("John"))
{
SQLiteDatabase db=(new MyDatabaseHelper(this)).getReadableDatabase();
Cursor cursor=db.rawQuery("SELECT Weather,Date,Status FROM Information WHERE Name = ?",new String[]{""+name1});
if(cursor.getCount()==1)
{
String weather=cursor.getString(cursor.getColumnIndex("Weather"));
String date=cursor.getString(cursor.getColumnIndex("Date"));
String status=cursor.getString(cursor.getColumnIndex("Status"));
}
db.close();
}
displaydata.xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp" >
<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:stretchColumns="|"
android:layout_marginBottom="25dp">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/tableRow1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView10"
android:background="#drawable/cell_shape"
android:textSize="17sp"
android:text="weather"/>
<TextView android:id="#+id/textView111"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="17sp"
android:background="#drawable/cell_shape"
android:text="date"/>
<TextView android:id="#+id/textView11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="17sp"
android:background="#drawable/cell_shape"
android:text="status"/>
</TableRow>
// <TableRow>
// <TextView android:id="#+id/textView1111"
// android:layout_width="wrap_content"
// android:layout_height="wrap_content"
// android:textSize="17sp"
// android:background="#drawable/cell_shape"/>
</TableRow>
</TableLayout>
</HorizontalScrollView>
</LinearLayout>
</ScrollView>
I also tried with this but no luck
TextView tvTemp=(TextView)findViewById(R.id.textView1111);
tvTemp.setText(weather + date + status);
The data should be retrieved and display in another class by row, not on editText. How can I do to achieve this?
Once you clicked yes,then you are moving to next activity and passing name to it:
public class DisplayData extends AppCompatActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.displaydata);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
Bundle bundle=getIntent().getExtras();
String name="";
if(bundle!=null)
{
name=bundle.getString("name");
}
//check whether you get the name value here or not..(use log)
SQLiteDatabase db=(new MyDatabaseHelper(this)).getReadableDatabase();
Cursor cursor=db.rawQuery("SELECT Weather,Date,Status FROM Information WHERE Name = ?",new String[]{""+name1});
if(cursor.getCount()==1)
{
String weather=cursor.getString(cursor.getColumnIndex("Weather"));//give the proper index of weather and same for rest.
String date=cursor.getString(cursor.getColumnIndex("Date"));
String status=cursor.getString(cursor.getColumnIndex("Status"));
}
db.close();
}