2012-05-12 19 views
0

sqliteデータベースで文字列を処理しようとしています。 sqlite VARCHARカラムにMultiline EditTextを保存する予定です 誰かがそれを行う方法を知っていますか?私はsqliteで複数行のEditTextを保存

abc 
123 
iiiiii 

edittext.getTextに入った私は唯一の1行たとえば

を得た()

私はEditText.getTextを使用するたびに()。のtoString、

  <EditText 
      android:id="@+id/edittext" 
      android:layout_width="267dp" 
      android:layout_height="73dp" 
      android:inputType="textCapSentences|textMultiLine" 
      android:singleLine="false" > 

( ).toString()のみ "abc"を返す!!!!

すべてのテキストをsqlite VARCHARカラムに保存するにはどうすればよいですか?

+1

「edittext」を読む場所にjavaセクションコードを投稿してください。あなたは問題なく複数行のテキストを読み込んで保存することができます。 – Sam

+0

edittext =(EditText)findViewById(R.id.multitext); edittext.getText()。toString(); – user1364080

答えて

2

何が起きているのかわかるように、コードをもっと投稿する必要があります。このXMLと組み合わせる

public class Example extends Activity implements OnClickListener { 
    @Override 
    public void onCreate(Bundle savedInstanceState) 
    { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 
    } 

    public void onClick(View view) { 
     //  Find the TextView,  set it's text from  the EditText 
     ((TextView) findViewById(R.id.text)).setText(((EditText) findViewById(R.id.edit)).getText()); 
    } 
} 

:このミニマルアプリ取りボタンをクリックするだけで

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

    <EditText 
     android:id="@+id/edit" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:hint="" /> 

    <Button 
     android:id="@+id/button" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:onClick="onClick" /> 

    <TextView 
     android:id="@+id/text" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" /> 

</LinearLayout> 

を、このベアボーンアプリは、複数行のEditTextを読み取り、別のものに、その内容を渡すの要件を満たしオブジェクト。この場合、文字列をTextViewに渡します。データベースのコードは基本的に同じです。それも、コピー「未知語」の色を強調する:

Screen Shot

を(つまり、データベースとバックにそう簡単にハイライト表示色をコピーすることを期待しないでください。)だから私が求める理由ですrealあなたのコードを選択しています。このプロセスで何かを変更しているので、私はここからエラーを見ることができません。

質問の編集機能を使用して、適切な機能を投稿してください。あなたは:EditTextを読んで、その内容をデータベースに保存し、後でそれを取得してください。

0
edittext = (EditText) findViewById(R.id.multitext); 
str=edittext.getText().toString()       
DBHelper req_task = new DBHelper(Send_req.this); 
req_task.createDataBase(); 
req_task.openDataBase(); 
req_task.writetext(str);