2016-06-12 50 views
-1

我是pharmD學生,剛剛在android開發中。我創建了一個應用程序,通過具體計算來計算患者的劑量。現在PharmD會輸入數據然後計算..等 我需要讓用戶可以在內部sd保存病人的病例然後在任何時候他需要看到它可以回去吧 所以首先;如何存儲我的文字如何在android項目中存儲和讀取文本?

EditText r11; 
r11 = (EditText) findViewById(R.id.Result); 
r11.setText(
          "\n------------------" + 
            "\nInputs" + 
            "\n------------------" + 
            "\n\nPatient Name:" + i1 + 
            "\nGender:" + i4 + 
            "\nRace:" + i5 + 
            "\nRoom:" + i2 + 
            "\nDate:" + i3 + 
            "\nAge (years):" + n4 + 
            "\nHeight (cm):" + n5 + 
            "\nWeight (Kg):" + n6 + 
            "\nSCR (mg/dl):" + n7 + 
            "\nTau (hrs):" + n8 + 
            "\nCss Avg (mg/L):" + n9 + 
            "\n\n\n------------------" + 
            "\nAnalysis:" + 
            "\n------------------" + 
            "\n\nIdeal Body Weight:" + r8.getText().toString() + " Kg" + 
            "\nAdjusted body weight:" + r9.getText().toString() + " Kg" + 
            "\nBody Surface Area:" + Html.fromHtml(r10.getText().toString() + " m<sup><small>2</small></sup>") + 
            "\nBody Mass Index:" + Html.fromHtml(r12.getText().toString() + " Kg/m<sup><small>2</small></sup>") + 
            "\n\n\n------------------" + 
            "\nDigoxin TDM :" + 
            "\n------------------" + 
            "\n\nVolume of Distribution:" + r4.getText().toString() + " L" + 
            "\nCockcroft & Gault:" + r1.getText().toString() + " ml/min" + 
            "\nCockcroft & Gault(adjusted for BSA):" + Html.fromHtml(r2.getText().toString() + " ml/min/1.73m<sup><small>2</small></sup>")+ 
            "\nDigoxin (CrCl):" + r3.getText().toString() + " L/day"+ 
            "\nElimination Rate Constant: " + r5.getText().toString() + " h<sup><small>-1</small></sup>"+ 
            "\nHalf Life:" + r6.getText().toString() + " hr" 

        ); 

其次;我想重新加載或閱讀它,所以用戶可以找到它!

我知道這是基本的Android開發,但我尊重任何的回答能幫助我在(代碼

感謝提前:)

回答

0

要快速持續的,你可以使用Android的sharedpreferences信息保存鍵值對的信息。

但是在這種情況下,我真的會建議你理解數據庫的概念,查看這個tutorial。它應該帶領您逐步實現您所需的數據組織。爲了快速說明(以極大的簡化),我們想到了一個名爲患者的Excel電子表格,每一行代表患者的數據,每一列代表您想存儲的信息(比賽,房間,日期,年齡)。那些有與之相關聯的數據類型,患者姓名是TEXT類型的信息,年齡是一個INTEGER號(年),但高度聽起來像一個REAL(如:1.75米)號等上。

+0

謝謝你:) – Ali

相關問題