Note that there are some explanatory texts on larger screens.

plurals
  1. POshowing "null" when value comes from another class of java android
    primarykey
    data
    text
    <p>i got the data from server when i go to use that value comes from server in another class it display null instead of actual value comes from server...i have two class activity2.java and notepadv3.java data comes from server in activity2.java and when i use that data it display null ...i am going to pasted both of the class...pls solve my problem why it shows null????? </p> <pre><code>package cabs.h; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.MalformedURLException; import java.net.URL; import android.app.ListActivity; import android.content.Intent; import android.content.SharedPreferences; import android.database.Cursor; import android.os.Bundle; import android.util.Log; import android.view.ContextMenu; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.ContextMenu.ContextMenuInfo; import android.widget.ListView; import android.widget.SimpleCursorAdapter; import android.widget.AdapterView.AdapterContextMenuInfo; public class Notepadv3 extends ListActivity { private static final int ACTIVITY_CREATE=0; private static final int ACTIVITY_EDIT=1; private static final int INSERT_ID = Menu.FIRST; private static final int DELETE_ID = Menu.FIRST + 1; private NotesDbAdapter mDbHelper; private Long mRowId; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.listonruntime); mDbHelper = new NotesDbAdapter(this); mDbHelper.open(); fillData(); registerForContextMenu(getListView()); } private void fillData() { Cursor notesCursor = mDbHelper.fetchAllNotes(); startManagingCursor(notesCursor); String s=NotesDbAdapter.KEY_TITLE; Log.i("saurabh trivedi log cat,,,,,,,,,",s); final String PREFS_NAME1 = "PrefSettings"; // Create an array to specify the fields we want to display in the list (only TITLE) String[] from = new String[]{NotesDbAdapter.KEY_BODY,NotesDbAdapter.KEY_TITLE}; // String[] too = new String[]{NotesDbAdapter.KEY_TITLE}; // and an array of the fields we want to bind those fields to (in this case just text1) int[] to = new int[]{R.id.toptext,R.id.middletext}; SimpleCursorAdapter notes = new SimpleCursorAdapter(this, R.layout.row, notesCursor, from, to); setListAdapter(notes); } @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); menu.add(0, DELETE_ID, 0, R.string.menu_delete); } @Override public boolean onContextItemSelected(MenuItem item) { switch(item.getItemId()) { case DELETE_ID: AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); mDbHelper.deleteNote(info.id); fillData(); return true; } return super.onContextItemSelected(item); } @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); saveState(); outState.putSerializable(NotesDbAdapter.KEY_ROWID, mRowId); } @Override protected void onPause() { super.onPause(); saveState(); } @Override protected void onResume() { super.onResume(); } </code></pre> <p>**</p> <pre><code>**//sss variabe value comes null when display it Activity2 activity=new Activity2(); String sss=activity.resp1; //String sss = cabbookingapplication.resp; String city = cabbookingapplication.Selection; private void saveState() { String title =("FROM LOC::"+sss); String body = ("TO LOC::"+city);** if (mRowId == null) {** long id = mDbHelper.createNote(title, body); if (id &gt; 0) { mRowId = id; } } else { mDbHelper.updateNote(mRowId, title, body); } @Override protected void onListItemClick(ListView l, View v, int position, long id) { super.onListItemClick(l, v, position, id); Intent i = new Intent(this,FeedActivity.class); startActivity(i); // i.putExtra(NotesDbAdapter.KEY_ROWID, id); // startActivityForResult(i, ACTIVITY_EDIT); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent intent) { super.onActivityResult(requestCode, resultCode, intent); fillData(); } } </code></pre> <p><strong>and Activity2.java class code is</strong></p> <pre><code>package cabs.h; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.MalformedURLException; import java.net.URL; import android.app.Activity; import android.os.Bundle; import android.util.Log; public class Activity2 extends Activity { public static String resp1; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); try { String tURL="http://qrrency.com/mobile/j2me/cab/CabRequestStatus.php?requestid=130"; URL url = new URL("http://qrrency.com/mobile/j2me/cab/CabRequestStatus.php?requestid=130"); Log.i("Line----saurabh trivedi-----", tURL); BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); int m=0; StringBuffer buffer=new StringBuffer(); String str1 = " "; while ((m=in.read())!=-1) { **buffer.append((char)m); str1=str1+(char)m; cabbookingapplication.resp =str1; resp1=cabbookingapplication.resp; Log.i("Line----saurabh trivedi---,,,--",resp1);** } in.close(); } catch (MalformedURLException e) { } catch (IOException e) { } Log.i("Line----saurabh trivedi---,,,--",resp1); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload