0

This is my 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 am trying to write a Person class to a raw folder using FileOutputStream, but nothing is working. Can't create a FileOutputStream, to get the raw folder file.

Also I tried a FileOutputStream.

 FileOutputStream fos = getBaseContext().openFileOutput(
     "android.resource://com.cpt.sample/raw/text.txt",MODE_PRIVATE);
Robert
  • 39,162
  • 17
  • 99
  • 152
Elis Seiti
  • 15
  • 1
  • 8

1 Answers1

1

You can't change resource file. They are static at run-time. you can check here.

And to put file at runtime you can use :

  • internal storage (or)
  • external storage

and to get this directories use : Environment.getExternalFilesDir()

Fore more information go here.

Community
  • 1
  • 1
Dharvik shah
  • 1,969
  • 12
  • 27