basic settings page just not working help needed

Problems with WiFi, SQLite ,Bluetooth, WiMax, Proxies, etc...

basic settings page just not working help needed

Postby matrix » Sun Dec 27, 2009 5:14 am

I am trying to create a basic settings page to store information I keep getting multiple errors. They are listed below:
Code: Select all
12-26 23:10:51.597: INFO/ActivityManager(5629): Starting activity: Intent { cmp=com.wispwatch.techdispatch/.appsettings }
12-26 23:10:52.537: ERROR/info(7921): info
12-26 23:10:52.537: ERROR/info(7921): android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0
12-26 23:10:52.537: ERROR/info(7921):     at android.database.AbstractCursor.checkPosition(AbstractCursor.java:580)
12-26 23:10:52.537: ERROR/info(7921):     at android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:214)
12-26 23:10:52.537: ERROR/info(7921):     at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:41)
12-26 23:10:52.537: ERROR/info(7921):     at com.wispwatch.techdispatch.appsettings.onCreate(appsettings.java:53)
12-26 23:10:52.537: ERROR/info(7921):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
12-26 23:10:52.537: ERROR/info(7921):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2417)
12-26 23:10:52.537: ERROR/info(7921):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2470)
12-26 23:10:52.537: ERROR/info(7921):     at android.app.ActivityThread.access$2200(ActivityThread.java:119)
12-26 23:10:52.537: ERROR/info(7921):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
12-26 23:10:52.537: ERROR/info(7921):     at android.os.Handler.dispatchMessage(Handler.java:99)
12-26 23:10:52.537: ERROR/info(7921):     at android.os.Looper.loop(Looper.java:123)
12-26 23:10:52.537: ERROR/info(7921):     at android.app.ActivityThread.main(ActivityThread.java:4310)
12-26 23:10:52.537: ERROR/info(7921):     at java.lang.reflect.Method.invokeNative(Native Method)
12-26 23:10:52.537: ERROR/info(7921):     at java.lang.reflect.Method.invoke(Method.java:521)
12-26 23:10:52.537: ERROR/info(7921):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
12-26 23:10:52.537: ERROR/info(7921):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
12-26 23:10:52.537: ERROR/info(7921):     at dalvik.system.NativeStart.main(Native Method)
12-26 23:10:53.157: INFO/ActivityManager(5629): Displayed activity com.wispwatch.techdispatch/.appsettings: 1420 ms (total 1420 ms)

And when the update button is clicked
Code: Select all
12-26 23:10:58.327: WARN/dalvikvm(7921): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
12-26 23:10:58.377: ERROR/AndroidRuntime(7921): Uncaught handler: thread main exiting due to uncaught exception
12-26 23:10:58.467: ERROR/AndroidRuntime(7921): java.lang.IllegalStateException: Could not find a method ABCD(View) in the activity
12-26 23:10:58.467: ERROR/AndroidRuntime(7921):     at android.view.View$1.onClick(View.java:2020)
12-26 23:10:58.467: ERROR/AndroidRuntime(7921):     at android.view.View.performClick(View.java:2364)
12-26 23:10:58.467: ERROR/AndroidRuntime(7921):     at android.view.View.onTouchEvent(View.java:4179)
12-26 23:10:58.467: ERROR/AndroidRuntime(7921):     at android.widget.TextView.onTouchEvent(TextView.java:6532)
12-26 23:10:58.467: ERROR/AndroidRuntime(7921):     at android.view.View.dispatchTouchEvent(View.java:3709)
12-26 23:10:58.467: ERROR/AndroidRuntime(7921):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882)
12-26 23:10:58.467: ERROR/AndroidRuntime(7921):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882)
12-26 23:10:58.467: ERROR/AndroidRuntime(7921):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882)
12-26 23:10:58.467: ERROR/AndroidRuntime(7921):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882)
12-26 23:10:58.467: ERROR/AndroidRuntime(7921):     at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659)
12-26 23:10:58.467: ERROR/AndroidRuntime(7921):     at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
12-26 23:10:58.467: ERROR/AndroidRuntime(7921):     at android.app.Activity.dispatchTouchEvent(Activity.java:2061)
12-26 23:10:58.467: ERROR/AndroidRuntime(7921):     at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
12-26 23:10:58.467: ERROR/AndroidRuntime(7921):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1690)
12-26 23:10:58.467: ERROR/AndroidRuntime(7921):     at android.os.Handler.dispatchMessage(Handler.java:99)
12-26 23:10:58.467: ERROR/AndroidRuntime(7921):     at android.os.Looper.loop(Looper.java:123)
12-26 23:10:58.467: ERROR/AndroidRuntime(7921):     at android.app.ActivityThread.main(ActivityThread.java:4310)
12-26 23:10:58.467: ERROR/AndroidRuntime(7921):     at java.lang.reflect.Method.invokeNative(Native Method)
12-26 23:10:58.467: ERROR/AndroidRuntime(7921):     at java.lang.reflect.Method.invoke(Method.java:521)
12-26 23:10:58.467: ERROR/AndroidRuntime(7921):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
12-26 23:10:58.467: ERROR/AndroidRuntime(7921):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
12-26 23:10:58.467: ERROR/AndroidRuntime(7921):     at dalvik.system.NativeStart.main(Native Method)
12-26 23:10:58.467: ERROR/AndroidRuntime(7921): Caused by: java.lang.NoSuchMethodException: ABCD
12-26 23:10:58.467: ERROR/AndroidRuntime(7921):     at java.lang.ClassCache.findMethodByName(ClassCache.java:308)
12-26 23:10:58.467: ERROR/AndroidRuntime(7921):     at java.lang.Class.getMethod(Class.java:1014)
12-26 23:10:58.467: ERROR/AndroidRuntime(7921):     at android.view.View$1.onClick(View.java:2017)
12-26 23:10:58.467: ERROR/AndroidRuntime(7921):     ... 21 more
12-26 23:10:58.527: INFO/Process(5629): Sending signal. PID: 7921 SIG: 3
12-26 23:10:58.537: INFO/dalvikvm(7921): threadid=7: reacting to signal 3
12-26 23:10:58.652: INFO/dalvikvm(7921): Wrote stack trace to '/data/anr/traces.txt'
12-26 23:11:01.268: INFO/Process(7921): Sending signal. PID: 7921 SIG: 9
12-26 23:11:01.407: INFO/ActivityManager(5629): Process com.wispwatch.techdispatch (pid 7921) has died.
12-26 23:11:01.497: INFO/WindowManager(5629): WIN DEATH: Window{43c90ad0 com.wispwatch.techdispatch/com.wispwatch.techdispatch.techdispatch paused=false}
12-26 23:11:01.507: INFO/WindowManager(5629): WIN DEATH: Window{43ca6e78 com.wispwatch.techdispatch/com.wispwatch.techdispatch.appsettings paused=false}
12-26 23:11:01.817: INFO/ActivityManager(5629): Start proc com.wispwatch.techdispatch for activity com.wispwatch.techdispatch/.techdispatch: pid=7946 uid=10030 gids={3003}
12-26 23:11:02.828: WARN/UsageStats(5629): Something wrong here, didn't expect com.wispwatch.techdispatch to be resumed
12-26 23:11:03.617: WARN/InputManagerService(5629): Got RemoteException sending setActive(false) notification to pid 7921 uid 10030
12-26 23:11:03.937: INFO/ActivityManager(5629): Displayed activity com.wispwatch.techdispatch/.techdispatch: 2344 ms (total 2344 ms)
12-26 23:11:04.327: ERROR/gralloc(5629): [unregister] handle 0x2c3940 still locked (state=40000001)


My Pages are as follows
Java:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package com.wispwatch.techdispatch;
  2.  
  3.  
  4.  
  5. import android.app.Activity;
  6.  
  7. import android.database.Cursor;
  8.  
  9. import android.database.sqlite.SQLiteDatabase;
  10.  
  11. import android.os.Bundle;
  12.  
  13. import android.util.Log;
  14.  
  15. import android.widget.Button;
  16.  
  17. import android.widget.EditText;
  18.  
  19. import android.widget.TextView;
  20.  
  21.  
  22.  
  23. public class appsettings extends Activity {
  24.  
  25.          /** Called when the activity is first created.  */
  26.  
  27.    String BaseURL="";
  28.  
  29.    String AuthURL="";
  30.  
  31.    String uname="";
  32.  
  33.    String passc="";
  34.  
  35.    String apikey="";
  36.  
  37.    String appurl="";    
  38.  
  39.    String TableName = "webSettings";
  40.  
  41.    EditText funame;
  42.  
  43.    EditText fpassc;
  44.  
  45.    EditText fapikey;
  46.  
  47.    EditText fappurl;
  48.  
  49.    Button updatebutton;
  50.  
  51.   @Override
  52.  
  53.   public void onCreate(Bundle savedInstanceState) {
  54.  
  55.    super.onCreate(savedInstanceState);
  56.  
  57.    setContentView(R.layout.settings);
  58.  
  59.    EditText funame = (EditText)findViewById(R.id.uname);
  60.  
  61.    EditText fpassc = (EditText)findViewById(R.id.passc);
  62.  
  63.    EditText fapikey = (EditText)findViewById(R.id.apikey);
  64.  
  65.    EditText fappurl = (EditText)findViewById(R.id.appurl);
  66.  
  67.    SQLiteDatabase myDB= null;
  68.  
  69.  
  70.  
  71.    try {
  72.  
  73.     myDB = this.openOrCreateDatabase("MyDatabase", MODE_PRIVATE, null);
  74.  
  75.  
  76.  
  77.     myDB.execSQL("CREATE TABLE IF NOT EXISTS "
  78.  
  79.       + TableName
  80.  
  81.       + " (id INTEGER, uname VARCHAR, passc VARCHAR, apikey VARCHAR, appurl VARCHAR);");
  82.  
  83.  
  84.  
  85.     Cursor c = myDB.rawQuery("SELECT * FROM " + TableName , null);
  86.  
  87.     int Column1 = c.getColumnIndex("uname");
  88.  
  89.     int Column2 = c.getColumnIndex("passc");
  90.  
  91.     int Column3 = c.getColumnIndex("apikey");
  92.  
  93.     int Column4 = c.getColumnIndex("appurl");
  94.  
  95.     // Check if our result was valid.
  96.  
  97.     c.moveToFirst();
  98.  
  99.     if (c != null) {
  100.  
  101.      // Loop through all Results
  102.  
  103.      do {
  104.  
  105.      uname = c.getString(Column1);
  106.  
  107.      passc = c.getString(Column2);
  108.  
  109.      apikey = c.getString(Column3);
  110.  
  111.      appurl = c.getString(Column4);
  112.  
  113.      
  114.  
  115.       BaseURL = appurl;
  116.  
  117.       AuthURL ="uname="+uname+"&passc="+passc+"&apikey="+apikey;
  118.  
  119.       funame.setText(uname);
  120.  
  121.       fpassc.setText(passc);
  122.  
  123.       fapikey.setText(apikey);
  124.  
  125.       fappurl.setText(appurl);
  126.  
  127.      }while(c.moveToNext());
  128.  
  129.  
  130.  
  131.     }
  132.  
  133.  
  134.  
  135.     if (AuthURL != null) {
  136.  
  137.        
  138.  
  139.     }
  140.  
  141.    TextView tv = new TextView(this);
  142.  
  143.  
  144.  
  145.     tv.setText(AuthURL);
  146.  
  147.    setContentView(tv);
  148.  
  149.  
  150.  
  151.    }
  152.  
  153.    catch(Exception e) {
  154.  
  155.    Log.e("info", "info", e);
  156.  
  157.    } finally {
  158.  
  159.     if (myDB != null)
  160.  
  161.  
  162.  
  163.      myDB.close();
  164.  
  165.  
  166.  
  167.    }
  168.  
  169.  
  170.  
  171.   }
  172.  
  173.   public void ABCD() {
  174.  
  175.         String formuname = (funame.getText().toString());
  176.  
  177.         String formfpassc= (fpassc.getText().toString());
  178.  
  179.         String formapikey= (fapikey.getText().toString());
  180.  
  181.         String formapiurl= (fappurl.getText().toString());
  182.  
  183.     updatebutton = (Button)findViewById(R.id.appurl);
  184.  
  185.         SQLiteDatabase myDB= null;
  186.  
  187.    setContentView(R.layout.settings);
  188.  
  189.            try {
  190.  
  191.             myDB = this.openOrCreateDatabase("MyDatabase", MODE_PRIVATE, null);
  192.  
  193.  
  194.  
  195. if (uname != null){
  196.  
  197.         myDB.execSQL("UPDATE  "
  198.  
  199.                      + TableName
  200.  
  201.                       + " SET uname='"+formuname+"', passc='"+formfpassc+"', apikey='"+formapikey+"', appurl='"+formapiurl+"'"
  202.  
  203.                      + " WHERE id = '1';");
  204.  
  205.                         updatebutton.setText("Updated");
  206.  
  207.         } else {
  208.  
  209.                     myDB.execSQL("INSERT INTO "
  210.  
  211.                      + TableName
  212.  
  213.                       + " (id, uname, passc, apikey, appurl)"
  214.  
  215.                      + " VALUES ('1', "+formuname+", "+formfpassc+", "+formapikey+", "+formapiurl+");");        
  216.  
  217.                     updatebutton.setText("Inserted");
  218.  
  219.        
  220.  
  221.         }
  222.  
  223.            }
  224.  
  225.            catch(Exception e) {
  226.  
  227.            Log.e("Error", "Error", e);
  228.  
  229.            } finally {
  230.  
  231.             if (myDB != null)
  232.  
  233.              myDB.close();
  234.  
  235.            }
  236.  
  237.           }
  238.  
  239. }
  240.  
  241.  
Parsed in 0.047 seconds, using GeSHi 1.0.8.4

and XML
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <?xml version="1.0" encoding="utf-8"?>
  3.  
  4. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  5.  
  6.    android:orientation="vertical"
  7.  
  8.    android:layout_width="fill_parent"
  9.  
  10.    android:layout_height="fill_parent"
  11.  
  12.    >
  13.  
  14.         <TextView
  15.  
  16. android:id="@+id/labelname"
  17.  
  18. android:layout_width="wrap_content"
  19.  
  20. android:layout_height="wrap_content"
  21.  
  22. android:text="Tech Portal Settings"
  23.  
  24. >
  25.  
  26. </TextView>
  27.  
  28. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  29.  
  30.    android:orientation="horizontal"
  31.  
  32.    android:layout_width="fill_parent"
  33.  
  34.    android:layout_height="wrap_content"
  35.  
  36.    >
  37.  
  38. <TextView
  39.  
  40. android:id="@+id/unamelabel"
  41.  
  42. android:layout_width="100px"
  43.  
  44. android:layout_height="wrap_content"
  45.  
  46. android:text="Your Username"
  47.  
  48. >
  49.  
  50. </TextView>
  51.  
  52. <EditText
  53.  
  54. android:id="@+id/uname"
  55.  
  56. android:layout_width="fill_parent"
  57.  
  58. android:layout_height="wrap_content"
  59.  
  60. android:text=""
  61.  
  62. android:textSize="18sp"
  63.  
  64. >
  65.  
  66. </EditText>
  67.  
  68. </LinearLayout>
  69.  
  70. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  71.  
  72.    android:orientation="horizontal"
  73.  
  74.    android:layout_width="fill_parent"
  75.  
  76.    android:layout_height="wrap_content"
  77.  
  78.    >
  79.  
  80. <TextView
  81.  
  82. android:id="@+id/passclabel"
  83.  
  84. android:layout_width="100px"
  85.  
  86. android:layout_height="wrap_content"
  87.  
  88. android:text="Your Password"
  89.  
  90. >
  91.  
  92. </TextView>
  93.  
  94. <EditText
  95.  
  96. android:id="@+id/passc"
  97.  
  98. android:layout_width="fill_parent"
  99.  
  100. android:layout_height="wrap_content"
  101.  
  102. android:text=""
  103.  
  104. android:textSize="18sp"
  105.  
  106. >
  107.  
  108. </EditText>
  109.  
  110. </LinearLayout>
  111.  
  112. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  113.  
  114.    android:orientation="horizontal"
  115.  
  116.    android:layout_width="fill_parent"
  117.  
  118.    android:layout_height="wrap_content"
  119.  
  120.    >
  121.  
  122. <TextView
  123.  
  124. android:id="@+id/apilabel"
  125.  
  126. android:layout_width="100px"
  127.  
  128. android:layout_height="wrap_content"
  129.  
  130. android:text="API KEY"
  131.  
  132. >
  133.  
  134. </TextView>
  135.  
  136. <EditText
  137.  
  138. android:id="@+id/apikey"
  139.  
  140. android:layout_width="fill_parent"
  141.  
  142. android:layout_height="wrap_content"
  143.  
  144. android:text=""
  145.  
  146. android:textSize="18sp"
  147.  
  148. >
  149.  
  150. </EditText>
  151.  
  152. </LinearLayout>
  153.  
  154. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  155.  
  156.    android:orientation="horizontal"
  157.  
  158.    android:layout_width="fill_parent"
  159.  
  160.    android:layout_height="wrap_content"
  161.  
  162.    >
  163.  
  164. <TextView
  165.  
  166. android:id="@+id/appurllabel"
  167.  
  168. android:layout_width="100px"
  169.  
  170. android:layout_height="wrap_content"
  171.  
  172. android:text="APP URL"
  173.  
  174. >
  175.  
  176. </TextView>
  177.  
  178. <EditText
  179.  
  180. android:id="@+id/appurl"
  181.  
  182. android:layout_width="fill_parent"
  183.  
  184. android:layout_height="wrap_content"
  185.  
  186. android:text=""
  187.  
  188. android:textSize="18sp"
  189.  
  190. >
  191.  
  192. </EditText>
  193.  
  194. </LinearLayout>
  195.  
  196. <Button
  197.  
  198. android:id="@+id/updatebutton"
  199.  
  200. android:onClick="ABCD"
  201.  
  202. android:layout_width="wrap_content"
  203.  
  204. android:layout_height="wrap_content"
  205.  
  206. android:text="Update"
  207.  
  208. >
  209.  
  210. </Button>
  211.  
  212. </LinearLayout>
  213.  
  214.  
Parsed in 0.011 seconds, using GeSHi 1.0.8.4


Any help would be appreciated or if there is a better way to achieve this please help.
matrix
Freshman
Freshman
 
Posts: 4
Joined: Tue Dec 22, 2009 5:07 am
Location: IN

Top

Postby matrix » Tue Dec 29, 2009 6:41 am

I have seen some really nice stuff come from this site, for someone experienced in Java and Android this should be fairly simple; I am just needing 4 fields to be constant in a database, just like if nearly any app that has preferences or settings. I could be soooo far of in my design its not funny, I don't know and I am not suck to this code. Is there anyone here who has made a form to set preferences or settings or even remotly close that can help out?
matrix
Freshman
Freshman
 
Posts: 4
Joined: Tue Dec 22, 2009 5:07 am
Location: IN

Top

Return to Networking & Database Problems

Who is online

Users browsing this forum: Google Feedfetcher, Yahoo [Bot] and 4 guests