java - How can I write an Object to my raw folder file -


this serializable class.

public class person implements serializable{ private string name; private string surname; private int age;   public person(string name,string surname,int age){     this.name = name;     this.surname = surname;     this.age = age; }  public void setsurname(string surname) {      this.surname = surname; }  public void setname(string name) {     this.name = name; } public void setage(int age){     this.age = age; }  public int getage() {     return age; }  public string getname() {     return name; }  public string getsurname() {     return surname; } public string tostring(){ return name + " "+surname+" "+age; } } 

i trying write person class raw folder using fileoutputstream, nothing working. can't create fileoutputstream, raw folder file.

also tried fileoutputstream.

 fileoutputstream fos = getbasecontext().openfileoutput(      "android.resource://com.cpt.sample/raw/text.txt",mode_private); 

you can't change resource file. static @ run-time. can check here.

and put file @ runtime can use :

  • internal storage (or)
  • external storage

and directories use : environment.getexternalfilesdir()

fore more information go here.


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -