0

我正在開發基於內容的Android App.I使用Firebase上傳所有文本文件(在rtf或doc文件中)。在將一個文本文件上傳到Firebase後,我創建了該下載從火力點,但文本文件無法讀取該文件提供詳細的活動,就說明nothing.Here是我的科特林代碼...如何將Firebase中的文本文件讀取到Android應用程序

class detailOne : AppCompatActivity() { 

    private var mTextView : TextView? = null 

    override fun onCreate(savedInstanceState: Bundle?) { 
     super.onCreate(savedInstanceState) 
     setContentView(R.layout.detailone) 

     val myButton = findViewById(R.id.butOne) as Button 
     mTextView = findViewById(R.id.myText) as TextView 

     FirebaseApp.initializeApp(this) 
     val storage = FirebaseStorage.getInstance() 
     val storageRef = storage.getReferenceFromUrl("gs://yehwot-eta.appspot.com/story.rtf") 


     try { 
      val localFile = File.createTempFile("text", "rtf") 
       storageRef.getFile(localFile).addOnSuccessListener { 

       }.addOnFailureListener { 
        print("Connection is Lost!Please Try Again") 
       } 
      } 
     } catch(e : IOException) { 
      e.printStackTrace() 
     } 

     myButton.setOnClickListener { 
      val myIntent = Intent() 
      myIntent.action = Intent.ACTION_SEND 
      myIntent.type = "text/plain"    
      myIntent.putExtra(Intent.EXTRA_TEXT,"This is my Text") 
      startActivity(myIntent) 
     } 
    } 
} 

回答

0

我已經得到了答案!爲了使用文本文件,我不必加載到Firebase存儲。相反,我會直接以Json格式上傳到Firebase數據庫。

相關問題